From acbdf73177846d97801503fc82c302369df47829 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 16 Sep 2018 02:57:35 -0400 Subject: [PATCH] Adds warning message if working file is missing --- src/commands/diffWithWorking.ts | 6 ++---- src/commands/openWorkingFile.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/commands/diffWithWorking.ts b/src/commands/diffWithWorking.ts index ef1df84..136ec62 100644 --- a/src/commands/diffWithWorking.ts +++ b/src/commands/diffWithWorking.ts @@ -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; diff --git a/src/commands/openWorkingFile.ts b/src/commands/openWorkingFile.ts index f9a654d..b0642c3 100644 --- a/src/commands/openWorkingFile.ts +++ b/src/commands/openWorkingFile.ts @@ -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); } }