From d9e638df01ea9ff3a0ed5df671a0617b1ac5a6af Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 16 Feb 2017 21:54:00 -0500 Subject: [PATCH] Adds config setting to control quickpick closing --- package.json | 5 +++++ src/commands/quickPicks.ts | 19 ++++++++++++++----- src/configuration.ts | 3 +++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f7d26ae..6598c3e 100644 --- a/package.json +++ b/package.json @@ -299,6 +299,11 @@ ], "description": "Specifies how much (if any) output will be sent to the GitLens output channel" }, + "gitlens.advanced.quickPick.closeOnFocusOut": { + "type": "boolean", + "default": true, + "description": "Specifies whether or not to close the QuickPick menu when focus is lost" + }, "gitlens.advanced.toggleWhitespace.enabled": { "type": "boolean", "default": false, diff --git a/src/commands/quickPicks.ts b/src/commands/quickPicks.ts index 098b555..ad2a99c 100644 --- a/src/commands/quickPicks.ts +++ b/src/commands/quickPicks.ts @@ -1,12 +1,17 @@ 'use strict'; import { Iterables } from '../system'; -import { QuickPickOptions, Uri, window } from 'vscode'; +import { QuickPickOptions, Uri, window, workspace } from 'vscode'; +import { IAdvancedConfig } from '../configuration'; import { Commands } from '../constants'; import { GitCommit, GitUri, IGitLog } from '../gitProvider'; import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem } from './quickPickItems'; import * as moment from 'moment'; import * as path from 'path'; +function getQuickPickIgnoreFocusOut() { + return !workspace.getConfiguration('gitlens').get('advanced').quickPick.closeOnFocusOut; +} + export class CommitQuickPick { static async show(commit: GitCommit, workingFileName: string, uri: Uri, currentCommand?: CommandQuickPickItem, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise { @@ -59,7 +64,8 @@ export class CommitQuickPick { return await window.showQuickPick(items, { matchOnDescription: true, - placeHolder: `${commit.fileName} \u2022 ${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}` + placeHolder: `${commit.fileName} \u2022 ${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`, + ignoreFocusOut: getQuickPickIgnoreFocusOut() } as QuickPickOptions); } } @@ -79,7 +85,8 @@ export class CommitFilesQuickPick { return await window.showQuickPick(items, { matchOnDescription: true, matchOnDetail: true, - placeHolder: `${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}` + placeHolder: `${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`, + ignoreFocusOut: getQuickPickIgnoreFocusOut() } as QuickPickOptions); } } @@ -116,7 +123,8 @@ export class FileCommitsQuickPick { return await window.showQuickPick(items, { matchOnDescription: true, matchOnDetail: true, - placeHolder: `${Iterables.first(log.commits.values()).fileName}` + placeHolder: `${Iterables.first(log.commits.values()).fileName}`, + ignoreFocusOut: getQuickPickIgnoreFocusOut() } as QuickPickOptions); } } @@ -141,7 +149,8 @@ export class RepoCommitsQuickPick { return await window.showQuickPick(items, { matchOnDescription: true, matchOnDetail: true, - placeHolder: 'Search by commit message, filename, or sha' + placeHolder: 'Search by commit message, filename, or sha', + ignoreFocusOut: getQuickPickIgnoreFocusOut() } as QuickPickOptions); } } \ No newline at end of file diff --git a/src/configuration.ts b/src/configuration.ts index cc6641d..1254063 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -109,6 +109,9 @@ export interface IAdvancedConfig { output: { level: OutputLevel; }; + quickPick: { + closeOnFocusOut: boolean; + }; toggleWhitespace: { enabled: boolean; };