Skip to content

Commit

Permalink
Fixes status file node commands in repos view
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jan 23, 2019
1 parent b08e46f commit cce8850
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion src/commands/copyRemoteFileUrlToClipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion src/commands/openFileInRemote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 14 additions & 12 deletions src/views/viewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)) ||
Expand Down Expand Up @@ -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 = {
Expand All @@ -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();
Expand All @@ -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 = {
Expand All @@ -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;
Expand Down

0 comments on commit cce8850

Please sign in to comment.