Skip to content

Commit

Permalink
quick search - file highlight decoration isn't showing up on search (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamah authored Aug 29, 2023
1 parent fbd61d1 commit 72d5c4d
Showing 1 changed file with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { CancellationToken } from 'vs/base/common/cancellation';
import { IMatch } from 'vs/base/common/filters';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import { basenameOrAuthority, dirname } from 'vs/base/common/resources';
import { ThemeIcon } from 'vs/base/common/themables';
import { IRange, Range } from 'vs/editor/common/core/range';
Expand All @@ -15,8 +15,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ILabelService } from 'vs/platform/label/common/label';
import { WorkbenchCompressibleObjectTree, getSelectionKeyboardEvent } from 'vs/platform/list/browser/listService';
import { FastAndSlowPicks, IPickerQuickAccessItem, PickerQuickAccessProvider, Picks } from 'vs/platform/quickinput/browser/pickerQuickAccess';
import { DefaultQuickAccessFilterValue } from 'vs/platform/quickinput/common/quickAccess';
import { IKeyMods, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { DefaultQuickAccessFilterValue, IQuickAccessProviderRunOptions } from 'vs/platform/quickinput/common/quickAccess';
import { IKeyMods, IQuickPick, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { IViewsService } from 'vs/workbench/common/views';
Expand Down Expand Up @@ -75,6 +75,19 @@ export class TextSearchQuickAccess extends PickerQuickAccessProvider<IPickerQuic
this.searchModel = this._instantiationService.createInstance(SearchModel);
}

override dispose(): void {
this.searchModel.dispose();
super.dispose();
}

override provide(picker: IQuickPick<IPickerQuickAccessItem>, token: CancellationToken, runOptions?: IQuickAccessProviderRunOptions): IDisposable {
const disposables = new DisposableStore();
disposables.add(super.provide(picker, token, runOptions));
disposables.add(picker.onDidHide(() => this.searchModel.searchResult.toggleHighlights(false)));
disposables.add(picker.onDidAccept(() => this.searchModel.searchResult.toggleHighlights(false)));
return disposables;
}

private get configuration() {
const editorConfig = this._configurationService.getValue<IWorkbenchEditorConfiguration>().workbench?.editor;
const searchConfig = this._configurationService.getValue<IWorkbenchSearchConfiguration>().search;
Expand Down Expand Up @@ -247,16 +260,24 @@ export class TextSearchQuickAccess extends PickerQuickAccessProvider<IPickerQuic
}
const matches = allMatches.syncResults;
const syncResult = this._getPicksFromMatches(matches, MAX_FILES_SHOWN);
if (syncResult.length > 0) {
this.searchModel.searchResult.toggleHighlights(true);
}

if (matches.length >= MAX_FILES_SHOWN) {
return syncResult;
}

return {
picks: syncResult,
additionalPicks: allMatches.asyncResults.then((asyncResults) => {
return this._getPicksFromMatches(asyncResults, MAX_FILES_SHOWN - matches.length);
})
additionalPicks: allMatches.asyncResults
.then(asyncResults => this._getPicksFromMatches(asyncResults, MAX_FILES_SHOWN - matches.length))
.then(picks => {
if (picks.length > 0) {
this.searchModel.searchResult.toggleHighlights(true);
}
return picks;
})
};

}
Expand Down

0 comments on commit 72d5c4d

Please sign in to comment.