Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

user input is kept in the subsequent search filter; fixes #255 #258

Merged
merged 2 commits into from
Jun 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/utils/filterUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

import { QuickPick, QuickPickItem, window, workspace } from "vscode";
import * as vscode from "vscode";

export async function resolveQuickPickHelper(
quickpick: QuickPick<QuickPickItem>
Expand All @@ -33,23 +34,38 @@ export class FilterDescriptor implements QuickPickItem {
}

export async function getPatternFromFilter(resourceName: string, resourceHistory:string[]) {
let pattern: string;
const desc = new FilterDescriptor(`\uFF0B Create New ${resourceName} Filter (use a comma to separate multiple patterns e.g. LG*,I*)`);
let pattern: string = "";
const createPick = new FilterDescriptor(`\uFF0B Create New ${resourceName} Filter (use a comma to separate multiple patterns e.g. LG*,I*)`);
const items = resourceHistory.map(loadedFilter => {
return { label: loadedFilter };
});
const choice = await window.showQuickPick([desc, ...items]);
const quickpick = vscode.window.createQuickPick();
quickpick.items = [createPick, ...items];
quickpick.placeholder = "Select a Filter";
quickpick.ignoreFocusOut = true;
quickpick.show();
const choice = await resolveQuickPickHelper(quickpick);
quickpick.hide();
if (!choice) {
window.showInformationMessage("No Selection Made");
vscode.window.showInformationMessage("No Selection Made");
return;
}
if (choice === desc) {
pattern = await window.showInputBox() || "";
if (choice instanceof FilterDescriptor) {
if (quickpick.value) {
pattern = quickpick.value;
}
} else {
pattern = await window.showInputBox({value:choice.label}) || "";
pattern = choice.label;
}
const options2: vscode.InputBoxOptions = {
prompt: "", value: pattern,
};
if (!options2.validateInput) {
options2.validateInput = (value) => null;
}
pattern = await vscode.window.showInputBox(options2) || "";
if (!pattern) {
window.showInformationMessage( "You must enter a pattern");
vscode.window.showInformationMessage("You must enter a pattern");
return;
}
// Replace with upper case
Expand Down