File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
data/fixtures/recorded/surroundingPair
packages/cursorless-engine/src/languages/TreeSitterQuery Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1+ languageId : typescriptreact
2+ command :
3+ version : 7
4+ spokenForm : change pair
5+ action :
6+ name : clearAndSetSelection
7+ target :
8+ type : primitive
9+ modifiers :
10+ - type : containingScope
11+ scopeType : {type: surroundingPair, delimiter: any}
12+ usePrePhraseSnapshot : false
13+ initialState :
14+ documentContents : |
15+ <div bbb={() => null}>hello &</div>
16+ selections :
17+ - anchor : {line: 0, character: 14}
18+ active : {line: 0, character: 14}
19+ marks : {}
20+ finalState :
21+ documentContents : |
22+ <div bbb=>hello &</div>
23+ selections :
24+ - anchor : {line: 0, character: 9}
25+ active : {line: 0, character: 9}
Original file line number Diff line number Diff line change @@ -6,10 +6,24 @@ import type { SyntaxNode } from "web-tree-sitter";
66 * @returns True if the given node is contained in an error node
77 */
88export function isContainedInErrorNode ( node : SyntaxNode ) {
9- let currentNode : SyntaxNode | null = node ;
9+ if ( node . hasError ) {
10+ return true ;
11+ }
12+
13+ let currentNode : SyntaxNode | null = node . parent ;
1014
1115 while ( currentNode != null ) {
16+ // Ancestral node has errors, but it was not siblings to the previous node
17+ // that caused the problem. We don't want to discard a node when a sibling
18+ // that isn't adjacent is erroring.
1219 if ( currentNode . hasError ) {
20+ return false ;
21+ }
22+ // A adjacent sibling node was causing the problem. ie we are right next to the error node.
23+ if (
24+ currentNode . previousSibling ?. isError ||
25+ currentNode . nextSibling ?. isError
26+ ) {
1327 return true ;
1428 }
1529 currentNode = currentNode . parent ;
You can’t perform that action at this time.
0 commit comments