Skip to content

Commit

Permalink
Allow selectParentSyntax to select nodes before the cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Sep 7, 2024
1 parent 0b78575 commit cf29578
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,11 @@ export const selectLine: StateCommand = ({state, dispatch}) => {
/// syntax tree.
export const selectParentSyntax: StateCommand = ({state, dispatch}) => {
let selection = updateSel(state.selection, range => {
let stack = syntaxTree(state).resolveStack(range.from, 1)
let tree = syntaxTree(state), stack = tree.resolveStack(range.from, 1)
if (range.empty) {
let stackBefore = tree.resolveStack(range.from, -1)
if (stackBefore.node.from >= stack.node.from && stackBefore.node.to <= stack.node.to) stack = stackBefore
}
for (let cur: typeof stack | null = stack; cur; cur = cur.next) {
let {node} = cur
if (((node.from < range.from && node.to >= range.to) ||
Expand Down

0 comments on commit cf29578

Please sign in to comment.