Add explicit replaceSelection() implementation

The $.textSelection() facade in CodeEditor is missing a
replaceSelection() implementation. This causes $.textSelection() to
fall back to a naive implementation, which does not work, thus breaking
any gadget or extension that tries to interact with CodeEditor using
this method. As a fix, provide a native replaceSelection()
implementation that calls the appropriate ACE editor method:

Bug: T342127
Change-Id: Ie3ed681b39c5d4d2bed50030a397a2b1c877c9fb
This commit is contained in:
Máté Szabó 2023-07-18 16:37:31 +02:00
parent 795d19bd6f
commit 2f7ce4dd50

View file

@ -733,6 +733,16 @@
return context.codeEditor.getCopyText();
},
/**
* Replace the current selection with the given text.
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
*
* @param {string} text
*/
replaceSelection: function ( text ) {
context.codeEditor.insert( text );
},
/**
* Inserts text at the begining and end of a text selection, optionally inserting text at the caret when
* selection is empty.