Skip to content

Commit

Permalink
Make gotoLine move scroll position to middle
Browse files Browse the repository at this point in the history
FIX: Make `gotoLine` prefer to scroll the target line to the middle of the view.
  • Loading branch information
bradymadden97 authored Jul 18, 2023
1 parent 388f05b commit ce45216
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/goto-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit ce45216

Please sign in to comment.