diff --git a/src/commands/copyRemoteFileUrlToClipboard.ts b/src/commands/copyRemoteFileUrlToClipboard.ts index cb63d31..fb58e32 100644 --- a/src/commands/copyRemoteFileUrlToClipboard.ts +++ b/src/commands/copyRemoteFileUrlToClipboard.ts @@ -24,7 +24,7 @@ export class CopyRemoteFileUrlToClipboardCommand extends ActiveEditorCommand { super(Commands.CopyRemoteFileUrlToClipboard); } - protected preExecute(context: CommandContext, args: CopyRemoteFileUrlToClipboardCommandArgs = { range: true }) { + protected preExecute(context: CommandContext, args?: CopyRemoteFileUrlToClipboardCommandArgs) { if (context.type === 'uris' || context.type === 'scm-states') { args = { ...args, range: false }; } else if (isCommandViewContextWithCommit(context)) { @@ -45,7 +45,9 @@ export class CopyRemoteFileUrlToClipboardCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args: CopyRemoteFileUrlToClipboardCommandArgs = { range: true }) { + async execute(editor?: TextEditor, uri?: Uri, args?: CopyRemoteFileUrlToClipboardCommandArgs) { + args = { range: true, ...args }; + if (args.sha === undefined) { uri = getCommandUri(uri, editor); if (uri == null) return undefined; diff --git a/src/commands/openFileInRemote.ts b/src/commands/openFileInRemote.ts index 70687e0..1de022b 100644 --- a/src/commands/openFileInRemote.ts +++ b/src/commands/openFileInRemote.ts @@ -31,10 +31,9 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand { super(Commands.OpenFileInRemote); } - protected preExecute(context: CommandContext, args: OpenFileInRemoteCommandArgs = { range: true }) { + protected preExecute(context: CommandContext, args?: OpenFileInRemoteCommandArgs) { if (isCommandViewContextWithCommit(context)) { - args = { ...args }; - args.range = false; + args = { ...args, range: false }; if (isCommandViewContextWithBranch(context)) { args.branch = context.node.branch !== undefined ? context.node.branch.name : undefined; } @@ -49,13 +48,15 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args: OpenFileInRemoteCommandArgs = { range: true }) { + async execute(editor?: TextEditor, uri?: Uri, args?: OpenFileInRemoteCommandArgs) { uri = getCommandUri(uri, editor); if (uri == null) return undefined; const gitUri = await GitUri.fromUri(uri); if (!gitUri.repoPath) return undefined; + args = { range: true, ...args }; + try { const remotes = await Container.git.getRemotes(gitUri.repoPath); const range = diff --git a/src/commands/stashApply.ts b/src/commands/stashApply.ts index 3b5dbf7..db439a6 100644 --- a/src/commands/stashApply.ts +++ b/src/commands/stashApply.ts @@ -27,19 +27,19 @@ export class StashApplyCommand extends Command { super(Commands.StashApply); } - protected preExecute(context: CommandContext, args: StashApplyCommandArgs = { deleteAfter: false }) { + protected preExecute(context: CommandContext, args?: StashApplyCommandArgs) { if (isCommandViewContextWithCommit(context)) { - args = { ...args }; - args.stashItem = context.node.commit; + args = { ...args, stashItem: context.node.commit }; } else if (isCommandViewContextWithRepo(context)) { - args = { ...args }; - args.repoPath = context.node.repo.path; + args = { ...args, repoPath: context.node.repo.path }; } return this.execute(args); } - async execute(args: StashApplyCommandArgs = { deleteAfter: false }) { + async execute(args?: StashApplyCommandArgs) { + args = { deleteAfter: false, ...args }; + let repo; if (args.stashItem !== undefined || args.repoPath !== undefined) { repo = await Container.git.getRepository((args.stashItem && args.stashItem.repoPath) || args.repoPath!);