- this.#dispatchChange(line.from, line.to, newLineContent, selectionRange.from + lineOffset);
- }
-
- /**
- * Dispatch changes to the editor.
- */
- #dispatchChange(from: number, to: number|null = null, text: string|null = null, selectFrom: number|null = null, selectTo: number|null = null): void {
- const change: ChangeSpec = {from};
- if (to) {
- change.to = to;
- }
- if (text) {
- change.insert = text;
- }
- const tr: TransactionSpec = {changes: change};
-
- if (selectFrom) {
- tr.selection = {anchor: selectFrom};
- if (selectTo) {
- tr.selection.head = selectTo;
- }
- }
-
- this.editor.cm.dispatch(tr);
- }
-
- /**
- * Set the current selection range.
- * Optionally will scroll the new range into view.
- * @param {Number} from
- * @param {Number} to
- * @param {Boolean} scrollIntoView
- */
- #setSelection(from: number, to: number, scrollIntoView = false) {
- this.editor.cm.dispatch({
- selection: {anchor: from, head: to},
- scrollIntoView,
- });
+ this.editor.input.spliceText(lineRange.from, lineRange.to, newLineContent, {from: selectionRange.from + lineOffset});