Skip to content

Commit cf29578

Browse files
committed
Allow selectParentSyntax to select nodes before the cursor
1 parent 0b78575 commit cf29578

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/commands.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,11 @@ export const selectLine: StateCommand = ({state, dispatch}) => {
401401
/// syntax tree.
402402
export const selectParentSyntax: StateCommand = ({state, dispatch}) => {
403403
let selection = updateSel(state.selection, range => {
404-
let stack = syntaxTree(state).resolveStack(range.from, 1)
404+
let tree = syntaxTree(state), stack = tree.resolveStack(range.from, 1)
405+
if (range.empty) {
406+
let stackBefore = tree.resolveStack(range.from, -1)
407+
if (stackBefore.node.from >= stack.node.from && stackBefore.node.to <= stack.node.to) stack = stackBefore
408+
}
405409
for (let cur: typeof stack | null = stack; cur; cur = cur.next) {
406410
let {node} = cur
407411
if (((node.from < range.from && node.to >= range.to) ||

0 commit comments

Comments
 (0)