Skip to content

Commit cb23567

Browse files
Added triple backtics matching pair to markdown language (#2775)
Triple backticks wasn't supported as a matching pair ## 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 8a68de7 commit cb23567

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
languageId: markdown
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+
```python
16+
a = 2
17+
```
18+
selections:
19+
- anchor: {line: 0, character: 0}
20+
active: {line: 0, character: 0}
21+
marks: {}
22+
finalState:
23+
documentContents: ""
24+
selections:
25+
- anchor: {line: 0, character: 0}
26+
active: {line: 0, character: 0}

packages/common/src/types/command/PartialTargetDescriptor.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export const simpleSurroundingPairNames = [
118118
"parentheses",
119119
"singleQuotes",
120120
"squareBrackets",
121+
"tripleBacktickQuotes",
121122
"tripleDoubleQuotes",
122123
"tripleSingleQuotes",
123124
] as const;

packages/cursorless-engine/src/generateSpokenForm/defaultSpokenForms/surroundingPairsDelimiters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const surroundingPairsDelimiters: Record<
1515
backtickQuotes: ["`", "`"],
1616
squareBrackets: ["[", "]"],
1717
singleQuotes: ["'", "'"],
18+
tripleBacktickQuotes: ["```", "```"],
1819
tripleDoubleQuotes: ['"""', '"""'],
1920
tripleSingleQuotes: ["'''", "'''"],
2021
whitespace: [" ", " "],

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ type DelimiterMap = Record<
2222
| [IndividualDelimiterText, IndividualDelimiterText, Options]
2323
>;
2424

25+
// Note that the order here is important since we are creating a regex from the key order.
26+
// For example triple quotes need to come before single quotes.
2527
const delimiterToText: DelimiterMap = Object.freeze({
2628
angleBrackets: [
2729
["</", "<"],
2830
[">", "/>"],
2931
],
30-
backtickQuotes: ["`", "`"],
3132
curlyBrackets: [["{", "${"], "}"],
33+
tripleBacktickQuotes: [[], []],
3234
tripleDoubleQuotes: [[], []],
3335
tripleSingleQuotes: [[], []],
3436
doubleQuotes: ['"', '"', { isSingleLine: true }],
@@ -37,6 +39,7 @@ const delimiterToText: DelimiterMap = Object.freeze({
3739
escapedSquareBrackets: ["\\[", "\\]"],
3840
escapedSingleQuotes: ["\\'", "\\'", { isSingleLine: true }],
3941
parentheses: [["(", "$("], ")"],
42+
backtickQuotes: ["`", "`"],
4043
singleQuotes: ["'", "'", { isSingleLine: true }],
4144
squareBrackets: ["[", "]"],
4245
});
@@ -63,6 +66,10 @@ const delimiterToTextOverrides: Record<string, Partial<DelimiterMap>> = {
6366
tripleDoubleQuotes: ['"""', '"""'],
6467
},
6568

69+
markdown: {
70+
tripleBacktickQuotes: ["```", "```"],
71+
},
72+
6673
ruby: {
6774
tripleDoubleQuotes: ["%Q(", ")"],
6875
},
@@ -84,6 +91,7 @@ export const complexDelimiterMap: Record<
8491
string: [
8592
"tripleDoubleQuotes",
8693
"tripleSingleQuotes",
94+
"tripleBacktickQuotes",
8795
"doubleQuotes",
8896
"singleQuotes",
8997
"backtickQuotes",

packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const defaultSpokenFormMapCore: DefaultSpokenFormMapDefinition = {
3030
singleQuotes: "twin",
3131
tripleDoubleQuotes: isPrivate("triple quad"),
3232
tripleSingleQuotes: isPrivate("triple twin"),
33+
tripleBacktickQuotes: isPrivate("triple skis"),
3334
any: "pair",
3435
string: "string",
3536
whitespace: "void",

0 commit comments

Comments
 (0)