From ce452167163b7bc18210fcf22b2672ec3275bc76 Mon Sep 17 00:00:00 2001 From: Brady Madden Date: Tue, 18 Jul 2023 12:40:59 -0400 Subject: [PATCH] Make gotoLine move scroll position to middle FIX: Make `gotoLine` prefer to scroll the target line to the middle of the view. --- src/goto-line.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/goto-line.ts b/src/goto-line.ts index 891d43b..5ab156d 100644 --- a/src/goto-line.ts +++ b/src/goto-line.ts @@ -38,10 +38,10 @@ function createLineDialog(view: EditorView): Panel { line = line * (sign == "-" ? -1 : 1) + startLine.number } let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line))) + let selection = EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length))) view.dispatch({ - effects: dialogEffect.of(false), - selection: EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length))), - scrollIntoView: true + effects: [dialogEffect.of(false), EditorView.scrollIntoView(selection.from, {y: 'center'})], + selection, }) view.focus() }