Parcourir la source

Ensures uri matches editor before getting a range

main
Eric Amodio il y a 5 ans
Parent
révision
5c03903da5
2 fichiers modifiés avec 7 ajouts et 5 suppressions
  1. +5
    -4
      src/commands/copyRemoteFileUrlToClipboard.ts
  2. +2
    -1
      src/commands/openFileInRemote.ts

+ 5
- 4
src/commands/copyRemoteFileUrlToClipboard.ts Voir le fichier

@ -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) {

+ 2
- 1
src/commands/openFileInRemote.ts Voir le fichier

@ -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 })

Chargement…
Annuler
Enregistrer