Skip to content

Commit d6e7034

Browse files
committed
fix: arg in execCommand for compatibility
1 parent 1179920 commit d6e7034

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cm/commandRegistry.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ function commandRunsInReadOnly(command, view) {
13001300
return view.state?.readOnly ? !!command.readOnly : true;
13011301
}
13021302

1303-
export function executeCommand(name, view) {
1303+
export function executeCommand(name, view, args) {
13041304
const command = resolveCommand(name);
13051305
if (!command) return false;
13061306
const targetView = command.requiresView
@@ -1309,7 +1309,7 @@ export function executeCommand(name, view) {
13091309
if (command.requiresView && !targetView) return false;
13101310
if (!commandRunsInReadOnly(command, targetView)) return false;
13111311
try {
1312-
const result = command.run(targetView);
1312+
const result = command.run(targetView, args);
13131313
return result !== false;
13141314
} catch (error) {
13151315
console.error(`Failed to execute command ${name}`, error);
@@ -1428,11 +1428,11 @@ function normalizeExternalCommand(descriptor) {
14281428
readOnly: !!descriptor?.readOnly,
14291429
requiresView,
14301430
key,
1431-
run(view) {
1431+
run(view, args) {
14321432
try {
14331433
const resolvedView = resolveView(view);
14341434
if (requiresView && !resolvedView) return false;
1435-
const result = exec(resolvedView || null);
1435+
const result = exec(resolvedView || null, args);
14361436
return result !== false;
14371437
} catch (error) {
14381438
console.error(`Command \"${name}\" failed`, error);

src/lib/acode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,10 @@ export default class Acode {
792792
this.#refreshCommandBindings();
793793
}
794794

795-
execCommand(name, view) {
795+
execCommand(name, view, args) {
796796
if (!name) return false;
797797
const targetView = view || window.editorManager?.editor;
798-
return runCommand(name, targetView);
798+
return runCommand(name, targetView, args);
799799
}
800800

801801
listCommands() {

src/lib/editorManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,9 @@ async function EditorManager($header, $body) {
645645

646646
await applyKeyBindings(editor);
647647

648-
editor.execCommand = function (commandName) {
648+
editor.execCommand = function (commandName, args) {
649649
if (!commandName) return false;
650-
return executeCommand(String(commandName), editor);
650+
return executeCommand(String(commandName), editor, args);
651651
};
652652

653653
editor.commands = {

0 commit comments

Comments
 (0)