Skip to content

Commit 031c16e

Browse files
committed
Scroll highlighted text to center of screen.
1 parent 172d3ee commit 031c16e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugins/editor/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ function editor(app, opts, done){
5151
const anchor = doc.posFromIndex(position);
5252
const head = doc.posFromIndex(position + length);
5353

54-
doc.setSelection(anchor, head);
54+
doc.setSelection(anchor, head, {
55+
scroll: false
56+
});
57+
58+
var top = codeEditor.charCoords(anchor, 'local').top;
59+
var halfHeight = codeEditor.getScrollerElement().offsetHeight / 2;
60+
codeEditor.scrollTo(null, top - halfHeight - 5);
5561
}
5662

5763
consoleStore.listen(refreshConsole);

0 commit comments

Comments
 (0)