Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #69843 - Navigate File Search History #88307

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cance
import { IStorageService } from 'vs/platform/storage/common/storage';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';

const HELP_PREFIX = '?';

Expand All @@ -74,6 +75,8 @@ export class QuickOpenController extends Component implements IQuickOpenService
private isQuickOpen: boolean | undefined;
private lastInputValue: string | undefined;
private lastSubmittedInputValue: string | undefined;
private inputHistory: string[] = ['', ''];
private inputHistoryIndex: number = 0;
private quickOpenWidget: QuickOpenWidget | undefined;
private mapResolvedHandlersToPrefix: Map<string, Promise<QuickOpenHandler>> = new Map();
private mapContextKeyToContext: Map<string, IContextKey<boolean>> = new Map();
Expand Down Expand Up @@ -104,6 +107,8 @@ export class QuickOpenController extends Component implements IQuickOpenService
this.updateConfiguration();

this.registerListeners();

this.registerCommands();
}

private registerListeners(): void {
Expand Down Expand Up @@ -283,6 +288,8 @@ export class QuickOpenController extends Component implements IQuickOpenService

// Events
this.emitQuickOpenVisibilityChange(false);

this.inputHistoryIndex = this.inputHistory.length - 1;
}

private cancelPendingGetResultsInvocation(): void {
Expand Down Expand Up @@ -336,6 +343,11 @@ export class QuickOpenController extends Component implements IQuickOpenService
private onOk(): void {
if (this.isQuickOpen) {
this.lastSubmittedInputValue = this.lastInputValue;
if (this.lastSubmittedInputValue) {
this.inputHistory[this.inputHistory.length - 1] = this.lastSubmittedInputValue;
this.inputHistory.push('');
this.inputHistoryIndex = this.inputHistory.length - 1;
}
}
}

Expand Down Expand Up @@ -627,6 +639,24 @@ export class QuickOpenController extends Component implements IQuickOpenService
this.quickOpenWidget.layout(dimension);
}
}

navigateInputHistory(arg?: any): void {
if (!this.quickOpenWidget) {
return;
}
if (arg === 'forwardInInputHistory' && this.inputHistoryIndex < this.inputHistory.length - 1) {
this.inputHistoryIndex++;
} else if (arg === 'backwardInInputHistory' && this.inputHistoryIndex > 0) {
this.inputHistoryIndex--;
}
this.quickOpenWidget.setValue(this.inputHistory[this.inputHistoryIndex]);
}

private registerCommands() {
CommandsRegistry.registerCommand('navigateInputHistory', (accessor, arg) => {
this.navigateInputHistory(arg);
});
}
}

class PlaceholderQuickOpenEntry extends QuickOpenEntryGroup {
Expand Down