Browse Source

Fixes status file node commands in repos view

main
Eric Amodio 5 years ago
parent
commit
cce8850901
4 changed files with 32 additions and 14 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +11
    -1
      src/commands/copyRemoteFileUrlToClipboard.ts
  3. +6
    -1
      src/commands/openFileInRemote.ts
  4. +14
    -12
      src/views/viewCommands.ts

+ 1
- 0
CHANGELOG.md View File

@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#626](https://github.com/eamodio/vscode-gitlens/issues/626) - Branch names with only digits always appear first — thanks to [PR #627](https://github.com/eamodio/vscode-gitlens/pull/627) by Marc Lasson ([@mlasson](https://github.com/mlasson))
- Fixes [#631](https://github.com/eamodio/vscode-gitlens/issues/631) - Remotes fail to show in gui
- Fixes [#633](https://github.com/eamodio/vscode-gitlens/issues/633) - Compare File with Previous Revision doesn't work if path contains '#'
- Fixes an issue where the _Open File_, _Open File on Remote_, and _Copy Remote Url to Clipboard_ commands didn't always work on changed files in the _Repositories_ view
## [9.4.1] - 2019-01-08

+ 11
- 1
src/commands/copyRemoteFileUrlToClipboard.ts View File

@ -2,6 +2,7 @@
import { commands, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitUri } from '../git/gitService';
import { StatusFileNode } from '../views/nodes';
import {
ActiveEditorCommand,
command,
@ -31,7 +32,16 @@ export class CopyRemoteFileUrlToClipboardCommand extends ActiveEditorCommand {
args.range = false;
args.sha = context.node.commit.sha;
return this.execute(context.editor, context.node.commit.uri, args);
// If it is a StatusFileNode then don't include the sha, since it hasn't been pushed yet
if (context.node instanceof StatusFileNode) {
args.sha = undefined;
}
return this.execute(
context.editor,
context.node.commit.isFile ? context.node.commit.uri : context.node.uri,
args
);
}
return this.execute(context.editor, context.uri, args);

+ 6
- 1
src/commands/openFileInRemote.ts View File

@ -39,7 +39,12 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
if (isCommandViewContextWithBranch(context)) {
args.branch = context.node.branch !== undefined ? context.node.branch.name : undefined;
}
return this.execute(context.editor, context.node.commit.uri, args);
return this.execute(
context.editor,
context.node.commit.isFile ? context.node.commit.uri : context.node.uri,
args
);
}
return this.execute(context.editor, context.uri, args);

+ 14
- 12
src/views/viewCommands.ts View File

@ -164,11 +164,7 @@ export class ViewCommands implements Disposable {
}
private async applyChanges(node: CommitFileNode | StashFileNode | ResultsFileNode) {
if (
!(node instanceof CommitFileNode) &&
!(node instanceof StashFileNode) &&
!(node instanceof ResultsFileNode)
) {
if (!(node instanceof CommitFileNode) && !(node instanceof ResultsFileNode)) {
return;
}
@ -244,7 +240,7 @@ export class ViewCommands implements Disposable {
Container.compareView.selectForCompare(node.repoPath, node.ref);
}
private compareFileWithSelected(node: CommitFileNode | StashFileNode | ResultsFileNode) {
private compareFileWithSelected(node: CommitFileNode | ResultsFileNode | StashFileNode) {
if (
this._selectedFile === undefined ||
(!(node instanceof CommitFileNode) && !(node instanceof ResultsFileNode)) ||
@ -278,7 +274,7 @@ export class ViewCommands implements Disposable {
private _selectedFile: ICompareSelected | undefined;
private selectFileForCompare(node: CommitFileNode | StashFileNode | ResultsFileNode) {
private selectFileForCompare(node: CommitFileNode | ResultsFileNode | StashFileNode) {
if ((!(node instanceof CommitFileNode) && !(node instanceof ResultsFileNode)) || node.ref === undefined) return;
this._selectedFile = {
@ -300,7 +296,7 @@ export class ViewCommands implements Disposable {
void commands.executeCommand(BuiltInCommands.FocusFilesExplorer);
}
private openChanges(node: CommitFileNode | StashFileNode | ResultsFileNode) {
private openChanges(node: CommitFileNode | ResultsFileNode | StashFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof ResultsFileNode)) return;
const command = node.getCommand();
@ -311,7 +307,7 @@ export class ViewCommands implements Disposable {
return commands.executeCommand(command.command, uri, args);
}
private async openChangesWithWorking(node: CommitFileNode | StashFileNode | ResultsFileNode) {
private async openChangesWithWorking(node: CommitFileNode | ResultsFileNode | StashFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof ResultsFileNode)) return;
const args: DiffWithWorkingCommandArgs = {
@ -332,14 +328,20 @@ export class ViewCommands implements Disposable {
return commands.executeCommand(Commands.DiffWithWorking, node.uri, args);
}
private openFile(node: CommitFileNode | StashFileNode | ResultsFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof ResultsFileNode)) return;
private openFile(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode) {
if (
!(node instanceof CommitFileNode) &&
!(node instanceof ResultsFileNode) &&
!(node instanceof StatusFileNode)
) {
return;
}
return openEditor(node.uri, { preserveFocus: true, preview: false });
}
private openFileRevision(
node: CommitFileNode | StashFileNode | ResultsFileNode,
node: CommitFileNode | ResultsFileNode | StashFileNode,
options: OpenFileRevisionCommandArgs = { showOptions: { preserveFocus: true, preview: false } }
) {
if (!(node instanceof CommitFileNode) && !(node instanceof ResultsFileNode)) return;

Loading…
Cancel
Save