Browse Source

Fixes #910 - show in search failed from views

main
Eric Amodio 5 years ago
parent
commit
231b0077b9
1 changed files with 25 additions and 17 deletions
  1. +25
    -17
      src/commands/showCommitsInView.ts

+ 25
- 17
src/commands/showCommitsInView.ts View File

@ -23,8 +23,6 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand {
args = { ...args };
if (args.refs === undefined) {
if (editor == null) return undefined;
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;
@ -32,23 +30,33 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand {
args.repoPath = gitUri.repoPath;
try {
// Check for any uncommitted changes in the range
const blame = editor.document.isDirty
? await Container.git.getBlameForRangeContents(gitUri, editor.selection, editor.document.getText())
: await Container.git.getBlameForRange(gitUri, editor.selection);
if (blame === undefined) {
return Messages.showFileNotUnderSourceControlWarningMessage(
'Unable to show commits in Search Commits view'
);
if (editor != null) {
try {
// Check for any uncommitted changes in the range
const blame = editor.document.isDirty
? await Container.git.getBlameForRangeContents(
gitUri,
editor.selection,
editor.document.getText()
)
: await Container.git.getBlameForRange(gitUri, editor.selection);
if (blame === undefined) {
return Messages.showFileNotUnderSourceControlWarningMessage(
'Unable to show commits in Search Commits view'
);
}
args.refs = [
...Iterables.filterMap(blame.commits.values(), c => (c.isUncommitted ? undefined : c.ref))
];
} catch (ex) {
Logger.error(ex, 'ShowCommitsInViewCommand', 'getBlameForRange');
return Messages.showGenericErrorMessage('Unable to show commits in Search Commits view');
}
} else {
if (gitUri.sha == null) return undefined;
args.refs = [
...Iterables.filterMap(blame.commits.values(), c => (c.isUncommitted ? undefined : c.ref))
];
} catch (ex) {
Logger.error(ex, 'ShowCommitsInViewCommand', 'getBlameForRange');
return Messages.showGenericErrorMessage('Unable to show commits in Search Commits view');
args.refs = [gitUri.sha];
}
}

Loading…
Cancel
Save