diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 00827778a0ef5..a26f887c442c3 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -1717,7 +1717,8 @@ export class CommandCenter { @command('git.commitMessageAccept') async commitMessageAccept(arg?: Uri): Promise { - if (!arg) { return; } + if (!arg && !window.activeTextEditor) { return; } + arg ??= window.activeTextEditor!.document.uri; // Close the tab this._closeEditorTab(arg); @@ -1725,11 +1726,12 @@ export class CommandCenter { @command('git.commitMessageDiscard') async commitMessageDiscard(arg?: Uri): Promise { - if (!arg) { return; } + if (!arg && !window.activeTextEditor) { return; } + arg ??= window.activeTextEditor!.document.uri; // Clear the contents of the editor const editors = window.visibleTextEditors - .filter(e => e.document.languageId === 'git-commit' && e.document.uri.toString() === arg.toString()); + .filter(e => e.document.languageId === 'git-commit' && e.document.uri.toString() === arg!.toString()); if (editors.length !== 1) { return; }