@@ -4,7 +4,7 @@ import {ref, onMounted} from 'vue';
4
4
import {lintKeymap } from ' @codemirror/lint' ;
5
5
import {EditorState } from ' @codemirror/state' ;
6
6
import {javascript } from ' @codemirror/lang-javascript' ;
7
- import {StateEffect , StateField } from ' @codemirror/state' ;
7
+ import {StateEffect , StateField , SelectionRange } from ' @codemirror/state' ;
8
8
import {defaultKeymap , history , historyKeymap } from ' @codemirror/commands' ;
9
9
import {highlightSelectionMatches , searchKeymap } from ' @codemirror/search' ;
10
10
import {autocompletion , closeBrackets , closeBracketsKeymap , completionKeymap } from ' @codemirror/autocomplete' ;
@@ -79,12 +79,13 @@ function highlightRange(start, end) {
79
79
this .dispatch ({
80
80
effects: highlightEffect .of ([highlight_decoration .range (start, end)]),
81
81
});
82
- const lineNumber = this . state . doc . lineAt (start). number ;
83
- const linePos = this . state . doc . line (lineNumber). from ;
84
- store . getEditor ( store . editorIds . inputCodeEditor ) .dispatch ({
85
- effects: EditorView .scrollIntoView (linePos , {
82
+ const range = new SelectionRange (start, end) ;
83
+ const ed = store . getEditor ( store . editorIds . inputCodeEditor ) ;
84
+ ed .dispatch ({
85
+ effects: EditorView .scrollIntoView (range , {
86
86
y: ' center' ,
87
- })
87
+ x: ' center' ,
88
+ }),
88
89
});
89
90
}
90
91
}
0 commit comments