Skip to content

Commit bc474c9

Browse files
committed
Fix cheatsheet
1 parent 518cd6e commit bc474c9

File tree

3 files changed

+58
-26
lines changed

3 files changed

+58
-26
lines changed

cursorless-talon/src/cheatsheet/sections/scopes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ def get_scopes():
1010
{
1111
"argumentOrParameter": "Argument",
1212
"boundedNonWhitespaceSequence": "Non whitespace sequence stopped by surrounding pair delimeters",
13-
"glyph": "stuff",
1413
},
1514
),
1615
{
1716
"id": "glyph",
18-
"type": "modifier",
17+
"type": "scopeType",
1918
"variations": [
2019
{
21-
"spokenForm": f"{complex_scopes['glyph']} <glyph>",
22-
"description": "First instance of <glyph>",
20+
"spokenForm": f"{complex_scopes['glyph']} <character>",
21+
"description": "Instance of single character <character>",
2322
},
2423
],
2524
},

packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
}
1515
]
1616
},
17+
{
18+
"id": "breakLine",
19+
"type": "action",
20+
"variations": [
21+
{
22+
"spokenForm": "break <target>",
23+
"description": "Break line"
24+
}
25+
]
26+
},
1727
{
1828
"id": "callAsFunction",
1929
"type": "action",
@@ -228,6 +238,16 @@
228238
}
229239
]
230240
},
241+
{
242+
"id": "joinLines",
243+
"type": "action",
244+
"variations": [
245+
{
246+
"spokenForm": "join <target>",
247+
"description": "Join lines"
248+
}
249+
]
250+
},
231251
{
232252
"id": "moveToTarget",
233253
"type": "action",
@@ -905,6 +925,16 @@
905925
"description": "Trailing delimiter range"
906926
}
907927
]
928+
},
929+
{
930+
"id": "visible",
931+
"type": "modifier",
932+
"variations": [
933+
{
934+
"spokenForm": "visible",
935+
"description": "Visible"
936+
}
937+
]
908938
}
909939
]
910940
},
@@ -1058,6 +1088,16 @@
10581088
}
10591089
]
10601090
},
1091+
{
1092+
"id": "show_scope_sidebar",
1093+
"type": "command",
1094+
"variations": [
1095+
{
1096+
"spokenForm": "bar cursorless",
1097+
"description": "Show cursorless sidebar"
1098+
}
1099+
]
1100+
},
10611101
{
10621102
"id": "show_scope_visualizer",
10631103
"type": "command",
@@ -1272,6 +1312,16 @@
12721312
}
12731313
]
12741314
},
1315+
{
1316+
"id": "glyph",
1317+
"type": "scopeType",
1318+
"variations": [
1319+
{
1320+
"spokenForm": "glyph <character>",
1321+
"description": "Instance of single character <character>"
1322+
}
1323+
]
1324+
},
12751325
{
12761326
"id": "identifier",
12771327
"type": "scopeType",
@@ -1537,7 +1587,7 @@
15371587
"type": "scopeType",
15381588
"variations": [
15391589
{
1540-
"spokenForm": "word",
1590+
"spokenForm": "sub",
15411591
"description": "Word"
15421592
}
15431593
]

packages/cursorless-engine/src/core/Cheatsheet.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import produce from "immer";
44
import { sortBy } from "lodash";
55
import { ide } from "../singletons/ide.singleton";
66
import path from "path";
7+
import { getCursorlessRepoRoot } from "@cursorless/common";
78

89
/**
910
* The argument expected by the cheatsheet command.
@@ -56,27 +57,9 @@ export async function showCheatsheet({
5657
* @param spokenFormInfo The new value to use for default spoken forms.
5758
*/
5859
export async function updateDefaults(spokenFormInfo: CheatsheetInfo) {
59-
const { runMode, assetsRoot, workspaceFolders } = ide();
60-
61-
const workspacePath =
62-
runMode === "development"
63-
? assetsRoot
64-
: workspaceFolders?.[0].uri.path ?? null;
65-
66-
if (workspacePath == null) {
67-
throw new Error(
68-
"Please update defaults from Cursorless workspace or running in debug",
69-
);
70-
}
71-
7260
const defaultsPath = path.join(
73-
workspacePath,
74-
"packages",
75-
"cheatsheet",
76-
"src",
77-
"lib",
78-
"sampleSpokenFormInfos",
79-
"defaults.json",
61+
getCursorlessRepoRoot(),
62+
"packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json",
8063
);
8164

8265
const outputObject = produce(spokenFormInfo, (draft) => {
@@ -86,7 +69,7 @@ export async function updateDefaults(spokenFormInfo: CheatsheetInfo) {
8669
});
8770
});
8871

89-
await writeFile(defaultsPath, JSON.stringify(outputObject, null, "\t"));
72+
await writeFile(defaultsPath, JSON.stringify(outputObject, null, 2) + "\n");
9073
}
9174

9275
// FIXME: Stop duplicating these types once we have #945

0 commit comments

Comments
 (0)