From 5d38937f34a6ca34b9875ab06421a76ad68c4e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Vi=E1=BB=87t=20H=C6=B0ng?= Date: Wed, 23 Jan 2019 00:20:50 +0700 Subject: [PATCH] scroll selected line to middle of the editor --- browser/components/CodeEditor.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 48634993..05da120b 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -835,6 +835,9 @@ export default class CodeEditor extends React.Component { ch: 1 } this.editor.setCursor(cursor) + const top = this.editor.charCoords({line: num, ch: 0}, 'local').top + const middleHeight = this.editor.getScrollerElement().offsetHeight / 2 + this.editor.scrollTo(null, top - middleHeight - 5) } focus () {