Skip to content

Commit 9d9079e

Browse files
committed
Calculate lineheight from char rect
1 parent 8cd1605 commit 9d9079e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

plugins/editor/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ function editor(app, opts, done){
5353

5454
doc.setSelection(anchor, head, { scroll: false });
5555

56-
const top = codeEditor.charCoords(anchor, 'local').top;
56+
const charRect = codeEditor.charCoords(anchor, 'local');
5757
const halfHeight = codeEditor.getScrollerElement().offsetHeight / 2;
58-
codeEditor.scrollTo(null, top - halfHeight - 5);
58+
const halfTextHeight = Math.floor((charRect.bottom - charRect.top) / 2);
59+
codeEditor.scrollTo(null, charRect.top - halfHeight - halfTextHeight);
5960
}
6061

6162
consoleStore.listen(refreshConsole);

0 commit comments

Comments
 (0)