Skip to content

Commit fbf2e4b

Browse files
committed
Rename system.invokeCommand syscall to editor.invokeCommand
1 parent 125d600 commit fbf2e4b

File tree

8 files changed

+29
-18
lines changed

8 files changed

+29
-18
lines changed

Library/Std/Config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,21 +263,21 @@ config.set {
263263
icon = "home",
264264
description = "Go to the index page",
265265
run = function()
266-
system.invokeCommand("Navigate: Home")
266+
editor.invokeCommand("Navigate: Home")
267267
end
268268
},
269269
{
270270
icon = "book",
271271
description = "Open page",
272272
run = function()
273-
system.invokeCommand("Navigate: Page Picker")
273+
editor.invokeCommand("Navigate: Page Picker")
274274
end
275275
},
276276
{
277277
icon = "terminal",
278278
description = "Run command",
279279
run = function()
280-
system.invokeCommand "Open Command Palette"
280+
editor.invokeCommand "Open Command Palette"
281281
end,
282282
}
283283
},

Library/Std/Widgets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function widgets.commandButton(text, commandName, args)
2626
end
2727
return widget.html(dom.button {
2828
onclick = function()
29-
system.invokeCommand(commandName, args)
29+
editor.invokeCommand(commandName, args)
3030
end,
3131
text
3232
})

plug-api/syscalls/editor.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ export function setSelection(from: number, to: number): Promise<void> {
9393
return syscall("editor.setSelection", from, to);
9494
}
9595

96+
/**
97+
* Invoke a client command by name
98+
* Note: only available on the client
99+
* @param name name of the command
100+
* @param args arguments to pass to the command
101+
*/
102+
export function invokeCommand(name: string, args?: string[]): Promise<any> {
103+
return syscall("editor.invokeCommand", name, args);
104+
}
105+
96106
/**
97107
* Forces a save of the current page
98108
*/

web/syscalls/editor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ export function editorSyscalls(client: Client): SysCallMapping {
117117
[],
118118
);
119119
},
120+
"editor.invokeCommand": (_ctx, name: string, args?: string[]) => {
121+
return client.runCommandByName(name, args);
122+
},
120123
"editor.openUrl": (_ctx, url: string, existingWindow = false) => {
121124
client.openUrl(url, existingWindow);
122125
},

web/syscalls/system.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ export function systemSyscalls(
4545
return client.clientSystem.localSyscall(name, args);
4646
},
4747
"system.invokeCommand": (_ctx, name: string, args?: string[]) => {
48-
if (!client) {
49-
throw new Error("Not supported");
50-
}
48+
console.warn("Deprecated, use editor.invokeCommand instead");
5149
return client.runCommandByName(name, args);
5250
},
5351
"system.listCommands": (): { [key: string]: CommandDef } => {

website/API/editor.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ Example:
116116
editor.moveCursorToLine(1, 1, true) -- Move to start of first line
117117
```
118118

119+
### editor.invokeCommand(name, args?)
120+
Invokes a client command by name.
121+
122+
Example:
123+
```lua
124+
editor.invokeCommand("Stats: Show")
125+
```
126+
119127
### editor.save()
120128
Force saves the current page.
121129

website/API/system.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ Example:
1313
system.invokeFunction("myplug.processData", "input", 123)
1414
```
1515

16-
### system.invokeCommand(name, args)
17-
Invokes a client command by name.
18-
19-
Example:
20-
```lua
21-
system.invokeCommand("editor.save", {})
22-
```
23-
2416
## System Information
2517

2618
### system.listCommands()

website/CONFIG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config.set {
1010
icon = "home",
1111
description = "Go to the index page",
1212
run = function()
13-
system.invokeCommand("Navigate: Home")
13+
editor.invokeCommand("Navigate: Home")
1414
end
1515
},
1616
{
@@ -33,14 +33,14 @@ config.set {
3333
icon = "book",
3434
description = "Open page",
3535
run = function()
36-
system.invokeCommand("Navigate: Page Picker")
36+
editor.invokeCommand("Navigate: Page Picker")
3737
end
3838
},
3939
{
4040
icon = "terminal",
4141
description = "Run command",
4242
run = function()
43-
system.invokeCommand "Open Command Palette"
43+
editor.invokeCommand "Open Command Palette"
4444
end,
4545
}
4646
},

0 commit comments

Comments
 (0)