Browse Source

Adds warning message if working file is missing

main
Eric Amodio 6 years ago
parent
commit
acbdf73177
2 changed files with 9 additions and 7 deletions
  1. +2
    -4
      src/commands/diffWithWorking.ts
  2. +7
    -3
      src/commands/openWorkingFile.ts

+ 2
- 4
src/commands/diffWithWorking.ts View File

@ -34,9 +34,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
// If the sha is missing, just let the user know the file matches
if (gitUri.sha === undefined) return window.showInformationMessage('File matches the working tree');
if (gitUri.sha === GitService.deletedOrMissingSha) {
return window.showInformationMessage(
'Unable to open compare. File has been deleted from the working tree'
);
return window.showWarningMessage('Unable to open compare. File has been deleted from the working tree');
}
// If we are a fake "staged" sha, check the status
@ -84,7 +82,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
const [workingFileName] = await Container.git.findWorkingFileName(gitUri.fsPath, gitUri.repoPath);
if (workingFileName === undefined) {
return window.showInformationMessage('Unable to open compare. File has been deleted from the working tree');
return window.showWarningMessage('Unable to open compare. File has been deleted from the working tree');
}
args.commit.workingFileName = workingFileName;

+ 7
- 3
src/commands/openWorkingFile.ts View File

@ -1,6 +1,6 @@
'use strict';
import * as path from 'path';
import { Range, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { FileAnnotationType } from '../configuration';
import { Container } from '../container';
import { GitUri } from '../git/gitService';
@ -37,9 +37,13 @@ export class OpenWorkingFileCommand extends ActiveEditorCommand {
args.uri.fsPath,
args.uri.repoPath
);
if (fileName !== undefined && repoPath !== undefined) {
args.uri = new GitUri(Uri.file(path.resolve(repoPath, fileName)), repoPath);
if (fileName === undefined) {
return window.showWarningMessage(
'Unable to open working file. File could not be found in the working tree'
);
}
args.uri = new GitUri(Uri.file(path.resolve(repoPath || '', fileName)), repoPath);
}
}

Loading…
Cancel
Save