Skip to content

Commit 0e4c9d9

Browse files
Better handling of escaped quotes in textual item (#1557)
Fixes #1551 ## 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
1 parent b1ecc92 commit 0e4c9d9

File tree

2 files changed

+32
-2
lines changed
  • packages

2 files changed

+32
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export function tokenizeRange(
4141
const lexemes = text
4242
// NB: Both the delimiters and the text between them are included because we
4343
// use a capture group in this split regex
44-
.split(/([,(){}<>[\]"'`]|\\"|\\'|\\`)/g)
45-
.filter((lexeme) => lexeme.length > 0);
44+
.split(/([,(){}<>[\]"'`])|(?<!\\)(\\"|\\'|\\`)/g)
45+
.filter((lexeme) => lexeme != null && lexeme.length > 0);
4646
const joinedLexemes = joinLexemesBySkippingMatchingPairs(lexemes);
4747
const tokens: Token[] = [];
4848
let offset = document.offsetAt(interior.start);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
"aaa": "\\",
16+
"bbb": "ccc",
17+
}
18+
selections:
19+
- anchor: {line: 1, character: 4}
20+
active: {line: 1, character: 4}
21+
marks: {}
22+
finalState:
23+
documentContents: |-
24+
values = {
25+
,
26+
"bbb": "ccc",
27+
}
28+
selections:
29+
- anchor: {line: 1, character: 4}
30+
active: {line: 1, character: 4}

0 commit comments

Comments
 (0)