diff --git a/CHANGELOG.md b/CHANGELOG.md index bd072b4..ac0899b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed +- Fixes [#2136](https://github.com/gitkraken/vscode-gitlens/issues/2136) - Search & Compare quickpick shouldn't select the mode text when opening - Fixes [#1896](https://github.com/gitkraken/vscode-gitlens/issues/1896) - Cannot read property 'fsPath' of undefined - Fixes [#1550](https://github.com/gitkraken/vscode-gitlens/issues/1550) - Push button in commit widget does not trigger "Push force" when ALT is pressed. - Fixes [#1991](https://github.com/gitkraken/vscode-gitlens/issues/1991) - Git lens status bar entry has an incomprehensible accessibility label diff --git a/src/commands/git/search.ts b/src/commands/git/search.ts index 6c702a0..195d758 100644 --- a/src/commands/git/search.ts +++ b/src/commands/git/search.ts @@ -315,6 +315,7 @@ export class SearchGitCommand extends QuickCommand { additionalButtons: [matchCaseButton, matchAllButton, matchRegexButton], items: items, value: state.pattern, + selectValueWhenShown: false, onDidAccept: (quickpick): boolean => { const pick = quickpick.selectedItems[0]; if (!searchOperators.has(pick.item)) return true; diff --git a/src/commands/gitCommands.ts b/src/commands/gitCommands.ts index cbd0e07..9c6581a 100644 --- a/src/commands/gitCommands.ts +++ b/src/commands/gitCommands.ts @@ -771,16 +771,25 @@ export class GitCommandsCommand extends Command { // Needs to be after we reset the command quickpick.buttons = this.getButtons(step, commandsStep.command); - if (step.value != null) { + const selectValueWhenShown = step.selectValueWhenShown ?? true; + if (step.value != null && selectValueWhenShown) { quickpick.value = step.value; } quickpick.show(); - // Manually trigger `onDidChangeValue`, because the QuickPick seems to fail to call it properly - if (step.value != null) { + if (step.value != null && !selectValueWhenShown) { + quickpick.value = step.value; + } + + // Manually trigger `onDidChangeValue`, because the QuickPick fails to call it if the value is set before it is shown + if (step.value != null && selectValueWhenShown) { // HACK: This is fragile! - (quickpick as any)._onDidChangeValueEmitter.fire(quickpick.value); + try { + (quickpick as any)._onDidChangeValueEmitter.fire(quickpick.value); + } catch { + debugger; + } } }); } finally { diff --git a/src/commands/quickCommand.steps.ts b/src/commands/quickCommand.steps.ts index f042749..722b78b 100644 --- a/src/commands/quickCommand.steps.ts +++ b/src/commands/quickCommand.steps.ts @@ -688,6 +688,7 @@ export async function* pickBranchOrTagStep< matchOnDescription: true, matchOnDetail: true, value: value, + selectValueWhenShown: true, items: branchesAndOrTags.length === 0 ? [DirectiveQuickPickItem.create(Directive.Back, true), DirectiveQuickPickItem.create(Directive.Cancel)] @@ -802,6 +803,7 @@ export async function* pickBranchOrTagStepMultiRepo< matchOnDescription: true, matchOnDetail: true, value: value ?? (GitReference.isRevision(state.reference) ? state.reference.ref : undefined), + selectValueWhenShown: true, items: branchesAndOrTags.length === 0 ? [DirectiveQuickPickItem.create(Directive.Back, true), DirectiveQuickPickItem.create(Directive.Cancel)] @@ -923,6 +925,7 @@ export async function* pickCommitStep< matchOnDescription: true, matchOnDetail: true, value: typeof picked === 'string' && log?.count === 0 ? picked : undefined, + selectValueWhenShown: true, items: showInSideBarCommand != null ? [showInSideBarCommand, ...getItems(log)] : getItems(log), onDidLoadMore: async quickpick => { quickpick.keepScrollPosition = true; diff --git a/src/commands/quickCommand.ts b/src/commands/quickCommand.ts index 886e687..baa7b91 100644 --- a/src/commands/quickCommand.ts +++ b/src/commands/quickCommand.ts @@ -54,6 +54,7 @@ export interface QuickPickStep { selectedItems?: QuickPickItem[]; title?: string; value?: string; + selectValueWhenShown?: boolean; onDidAccept?(quickpick: QuickPick): boolean | Promise; onDidChangeValue?(quickpick: QuickPick): boolean | Promise;