Skip to content

Commit 61cf9c4

Browse files
committed
Allow use of contiguous or fuzzy search in run recent
1 parent 0c12daf commit 61cf9c4

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
818818
this._linkManager.openRecentLink(type);
819819
}
820820

821-
async runRecent(type: 'command' | 'cwd'): Promise<void> {
821+
async runRecent(type: 'command' | 'cwd', filterMode?: 'fuzzy' | 'contiguous'): Promise<void> {
822822
if (!this.xterm) {
823823
return;
824824
}
@@ -968,25 +968,40 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
968968
const originalItems = items;
969969
quickPick.items = [...originalItems];
970970
quickPick.sortByLabel = false;
971-
quickPick.matchOnLabel = false;
972971
quickPick.placeholder = placeholder;
973972
quickPick.title = 'Run Recent Command';
974-
quickPick.onDidChangeValue(value => {
975-
quickPick.items = originalItems.filter(item => {
976-
if (item.type === 'separator') {
977-
return true;
978-
}
979-
item.highlights = undefined;
980-
const matchIndex = item.label.indexOf(value);
981-
if (matchIndex !== -1) {
982-
item.highlights = {
983-
label: [{ start: matchIndex, end: matchIndex + value.length }]
984-
};
985-
return true;
986-
}
987-
return false;
973+
quickPick.customButton = true;
974+
quickPick.matchOnLabel = filterMode === 'fuzzy';
975+
if (filterMode === 'fuzzy') {
976+
quickPick.customLabel = nls.localize('terminal.contiguousSearch', 'Use Contiguous Search');
977+
quickPick.onDidCustom(() => {
978+
quickPick.hide();
979+
this.runRecent(type, 'contiguous');
988980
});
989-
});
981+
} else {
982+
// contiguous is the default for command
983+
quickPick.onDidChangeValue(value => {
984+
quickPick.items = originalItems.filter(item => {
985+
if (item.type === 'separator') {
986+
return true;
987+
}
988+
item.highlights = undefined;
989+
const matchIndex = item.label.indexOf(value);
990+
if (matchIndex !== -1) {
991+
item.highlights = {
992+
label: [{ start: matchIndex, end: matchIndex + value.length }]
993+
};
994+
return true;
995+
}
996+
return false;
997+
});
998+
});
999+
quickPick.customLabel = nls.localize('terminal.fuzzySearch', 'Use Fuzzy Search');
1000+
quickPick.onDidCustom(() => {
1001+
quickPick.hide();
1002+
this.runRecent(type, 'fuzzy');
1003+
});
1004+
}
9901005
quickPick.onDidTriggerItemButton(async e => {
9911006
if (e.button === removeFromCommandHistoryButton) {
9921007
if (type === 'command') {

0 commit comments

Comments
 (0)