diff --git a/src/commands/copyRemoteFileUrlToClipboard.ts b/src/commands/copyRemoteFileUrlToClipboard.ts index 140d967..2aead55 100644 --- a/src/commands/copyRemoteFileUrlToClipboard.ts +++ b/src/commands/copyRemoteFileUrlToClipboard.ts @@ -24,10 +24,11 @@ export class CopyRemoteFileUrlToClipboardCommand extends ActiveEditorCommand { } protected preExecute(context: CommandContext, args: CopyRemoteFileUrlToClipboardCommandArgs = { range: true }) { - if (isCommandViewContextWithCommit(context)) { - args = { ...args }; - args.range = false; - args.sha = context.node.commit.sha; + if (context.type === 'uri' || context.type === 'scm-states') { + args = { ...args, range: false }; + } + else if (isCommandViewContextWithCommit(context)) { + args = { ...args, range: false, sha: context.node.commit.sha }; // If it is a StatusFileNode then don't include the sha, since it hasn't been pushed yet if (context.node instanceof StatusFileNode) { diff --git a/src/commands/openFileInRemote.ts b/src/commands/openFileInRemote.ts index 0f80a69..8521951 100644 --- a/src/commands/openFileInRemote.ts +++ b/src/commands/openFileInRemote.ts @@ -16,6 +16,7 @@ import { } from './common'; import { OpenInRemoteCommandArgs } from './openInRemote'; import { Strings } from '../system'; +import { UriComparer } from '../comparers'; export interface OpenFileInRemoteCommandArgs { branch?: string; @@ -58,7 +59,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand { try { const remotes = await Container.git.getRemotes(gitUri.repoPath); const range = - args.range && editor != null + args.range && editor != null && UriComparer.equals(editor.document.uri, uri) ? new Range( editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 })