From cc7fe1fd46e3a759a09651a6cdf7203eb99cefe9 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 29 Nov 2017 04:12:47 -0500 Subject: [PATCH] Fixes cases of stuck progress indicators --- CHANGELOG.md | 2 ++ src/commands/diffWithRevision.ts | 5 ++++- src/commands/showCommitSearch.ts | 10 ++++++---- src/quickPicks/commits.ts | 6 +++--- src/quickPicks/common.ts | 13 ++++++++++--- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 077c45e..6cbf7f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Fixes 🤞 [#216](https://github.com/eamodio/vscode-gitlens/issues/216) - PowerShell session not started if GitLen is enabled - Fixes [#217](https://github.com/eamodio/vscode-gitlens/issues/217) - empty editor has git lens in status bar with old information - Fixes [#218](https://github.com/eamodio/vscode-gitlens/issues/218) - Cannot read property 'replace' of undefined +- Fixes issue with feedback when searching for commits without any matches +- Fixes issue where quickpick progress indicators could get stuck ## [6.2.0] - 2017-11-27 ### Added diff --git a/src/commands/diffWithRevision.ts b/src/commands/diffWithRevision.ts index 7c37175..1f09d99 100644 --- a/src/commands/diffWithRevision.ts +++ b/src/commands/diffWithRevision.ts @@ -67,5 +67,8 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand { Logger.error(ex, 'DiffWithRevisionCommand'); return window.showErrorMessage(`Unable to open compare. See output channel for more details`); } - } + finally { + progressCancellation.dispose(); + } + } } \ No newline at end of file diff --git a/src/commands/showCommitSearch.ts b/src/commands/showCommitSearch.ts index 94e62ef..0f58aa7 100644 --- a/src/commands/showCommitSearch.ts +++ b/src/commands/showCommitSearch.ts @@ -86,7 +86,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { switch (args.searchBy) { case GitRepoSearchBy.Author: originalSearch = `@${args.search}`; - placeHolder = `commits with author matching '${args.search}'`; + placeHolder = `commits with an author matching '${args.search}'`; break; case GitRepoSearchBy.Changes: @@ -106,19 +106,18 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { case GitRepoSearchBy.Message: originalSearch = args.search; - placeHolder = `commits with message matching '${args.search}'`; + placeHolder = `commits with a message matching '${args.search}'`; break; case GitRepoSearchBy.Sha: originalSearch = `#${args.search}`; - placeHolder = `commits with id matching '${args.search}'`; + placeHolder = `commits with an id matching '${args.search}'`; break; } const progressCancellation = CommitsQuickPick.showProgress(placeHolder!); try { const log = await this.git.getLogForRepoSearch(repoPath, args.search, args.searchBy); - if (log === undefined) return undefined; if (progressCancellation.token.isCancellationRequested) return undefined; @@ -157,5 +156,8 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { Logger.error(ex, 'ShowCommitSearchCommand'); return window.showErrorMessage(`Unable to find commits. See output channel for more details`); } + finally { + progressCancellation.dispose(); + } } } \ No newline at end of file diff --git a/src/quickPicks/commits.ts b/src/quickPicks/commits.ts index effce62..88df2a3 100644 --- a/src/quickPicks/commits.ts +++ b/src/quickPicks/commits.ts @@ -3,7 +3,7 @@ import { Iterables } from '../system'; import { CancellationTokenSource, QuickPickOptions, window } from 'vscode'; import { GitLog, GitService } from '../gitService'; import { Keyboard, KeyNoopCommand } from '../keyboard'; -import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from '../quickPicks'; +import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, MessageQuickPickItem, showQuickPickProgress } from '../quickPicks'; export class CommitsQuickPick { @@ -16,8 +16,8 @@ export class CommitsQuickPick { }); } - static async show(git: GitService, log: GitLog, placeHolder: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem): Promise { - const items = ((log && [...Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))]) || []) as (CommitQuickPickItem | CommandQuickPickItem)[]; + static async show(git: GitService, log: GitLog | undefined, placeHolder: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem): Promise { + const items = ((log && [...Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))]) || [new MessageQuickPickItem('No results found')]) as (CommitQuickPickItem | CommandQuickPickItem)[]; if (goBackCommand !== undefined) { items.splice(0, 0, goBackCommand); diff --git a/src/quickPicks/common.ts b/src/quickPicks/common.ts index d23599d..da00e17 100644 --- a/src/quickPicks/common.ts +++ b/src/quickPicks/common.ts @@ -104,6 +104,13 @@ export class CommandQuickPickItem implements QuickPickItem { } } +export class MessageQuickPickItem extends CommandQuickPickItem { + + constructor(message: string) { + super({ label: message, description: '' } as QuickPickItem); + } +} + export class KeyCommandQuickPickItem extends CommandQuickPickItem { constructor(command: Commands, args?: any[]) { @@ -113,7 +120,7 @@ export class KeyCommandQuickPickItem extends CommandQuickPickItem { export class OpenFileCommandQuickPickItem extends CommandQuickPickItem { - constructor(public uri: Uri, item: QuickPickItem) { + constructor(public readonly uri: Uri, item: QuickPickItem) { super(item, undefined, undefined); } @@ -138,7 +145,7 @@ export class OpenFileCommandQuickPickItem extends CommandQuickPickItem { export class OpenFilesCommandQuickPickItem extends CommandQuickPickItem { - constructor(public uris: Uri[], item: QuickPickItem) { + constructor(public readonly uris: Uri[], item: QuickPickItem) { super(item, undefined, undefined); } @@ -163,7 +170,7 @@ export class CommitQuickPickItem implements QuickPickItem { description: string; detail: string; - constructor(public commit: GitCommit) { + constructor(public readonly commit: GitCommit) { let message = commit.message; const index = message.indexOf('\n'); if (index !== -1) {