Skip to content

Commit 6076d86

Browse files
Item: Ignore unmatched starting delimiter (#1559)
## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [ ] I have not broken the cheatsheet --------- Co-authored-by: Pokey Rule <[email protected]>
1 parent 7a77402 commit 6076d86

File tree

2 files changed

+36
-1
lines changed
  • packages

2 files changed

+36
-1
lines changed

packages/cursorless-engine/src/processTargets/modifiers/ItemStage/tokenizeRange.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ export function joinLexemesBySkippingMatchingPairs(lexemes: string[]) {
128128
}
129129

130130
// Starting delimiter found
131-
else if (leftToRightMap[lexeme] != null) {
131+
// Make sure that there is a matching closing delimiter
132+
else if (
133+
leftToRightMap[lexeme] != null &&
134+
lexemes.indexOf(leftToRightMap[lexeme], index + 1) > -1
135+
) {
132136
openingDelimiter = lexeme;
133137
closingDelimiter = leftToRightMap[lexeme];
134138
delimiterBalance = 1;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
languageId: plaintext
2+
command:
3+
version: 5
4+
spokenForm: clear item
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: containingScope
10+
scopeType: {type: collectionItem}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |-
14+
values = [
15+
111, // don't ...
16+
222,
17+
333
18+
]
19+
selections:
20+
- anchor: {line: 2, character: 4}
21+
active: {line: 2, character: 4}
22+
marks: {}
23+
finalState:
24+
documentContents: |-
25+
values = [
26+
111, ,
27+
333
28+
]
29+
selections:
30+
- anchor: {line: 1, character: 9}
31+
active: {line: 1, character: 9}

0 commit comments

Comments
 (0)