From 80a9557b4afe739fee4659f87f77718895c3b737 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 13 Sep 2018 10:49:09 +0200 Subject: [PATCH] fix #30770 --- .../parts/quickopen/quickOpenController.ts | 15 ++++++++++++--- src/vs/workbench/browser/quickopen.ts | 1 + .../electron-browser/search.contribution.ts | 5 +++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index d3d4c3be25a..4a561b7c681 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -29,7 +29,7 @@ import { EditorInput, IWorkbenchEditorConfiguration, IEditorInput } from 'vs/wor import { Component } from 'vs/workbench/common/component'; import { Event, Emitter } from 'vs/base/common/event'; import { IPartService } from 'vs/workbench/services/part/common/partService'; -import { QuickOpenHandler, QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions, EditorQuickOpenEntry, CLOSE_ON_FOCUS_LOST_CONFIG } from 'vs/workbench/browser/quickopen'; +import { QuickOpenHandler, QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions, EditorQuickOpenEntry, CLOSE_ON_FOCUS_LOST_CONFIG, SEARCH_EDITOR_HISTORY } from 'vs/workbench/browser/quickopen'; import * as errors from 'vs/base/common/errors'; import { IQuickOpenService, IShowOptions } from 'vs/platform/quickOpen/common/quickOpen'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -77,6 +77,7 @@ export class QuickOpenController extends Component implements IQuickOpenService private previousActiveHandlerDescriptor: QuickOpenHandlerDescriptor; private actionProvider = new ContributableActionProvider(); private closeOnFocusLost: boolean; + private searchInEditorHistory: boolean; private editorHistoryHandler: EditorHistoryHandler; private pendingGetResultsInvocation: CancellationTokenSource; @@ -111,6 +112,8 @@ export class QuickOpenController extends Component implements IQuickOpenService } else { this.closeOnFocusLost = this.configurationService.getValue(CLOSE_ON_FOCUS_LOST_CONFIG); } + + this.searchInEditorHistory = this.configurationService.getValue(SEARCH_EDITOR_HISTORY); } navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration): void { @@ -403,8 +406,14 @@ export class QuickOpenController extends Component implements IQuickOpenService private handleDefaultHandler(handler: QuickOpenHandlerDescriptor, value: string, token: CancellationToken): TPromise { - // Fill in history results if matching - const matchingHistoryEntries = this.editorHistoryHandler.getResults(value, token); + // Fill in history results if matching and we are configured to search in history + let matchingHistoryEntries: QuickOpenEntry[]; + if (value && !this.searchInEditorHistory) { + matchingHistoryEntries = []; + } else { + matchingHistoryEntries = this.editorHistoryHandler.getResults(value, token); + } + if (matchingHistoryEntries.length > 0) { matchingHistoryEntries[0] = new EditorHistoryEntryGroup(matchingHistoryEntries[0], nls.localize('historyMatches', "recently opened"), false); } diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index 3675ccf763e..7d602322926 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -22,6 +22,7 @@ import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/ import { CancellationToken } from 'vs/base/common/cancellation'; export const CLOSE_ON_FOCUS_LOST_CONFIG = 'workbench.quickOpen.closeOnFocusLost'; +export const SEARCH_EDITOR_HISTORY = 'search.quickOpen.includeHistory'; export interface IWorkbenchQuickOpenConfiguration { workbench: { diff --git a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts index 1b50a6691ce..6dc9af5e9e6 100644 --- a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts +++ b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts @@ -602,6 +602,11 @@ configurationRegistry.registerConfiguration({ description: nls.localize('search.quickOpen.includeSymbols', "Whether to include results from a global symbol search in the file results for Quick Open."), default: false }, + 'search.quickOpen.includeHistory': { + type: 'boolean', + description: nls.localize('search.quickOpen.includeHistory', "Whether to include results from recently opened files in the file results for Quick Open."), + default: true + }, 'search.followSymlinks': { type: 'boolean', description: nls.localize('search.followSymlinks', "Controls whether to follow symlinks while searching."), -- GitLab