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

Commit

Permalink
Merge pull request #258 from zowe/search-filter-input-preserve
Browse files Browse the repository at this point in the history
user input is kept in the subsequent search filter; fixes #255
  • Loading branch information
JeffinSiby committed Jun 23, 2022
2 parents 9526b4c + ec88875 commit b224582
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/utils/filterUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

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

export async function resolveQuickPickHelper(
quickpick: QuickPick<QuickPickItem>
Expand All @@ -33,23 +33,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 = 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");
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: InputBoxOptions = {
prompt: "", value: pattern,
};
if (!options2.validateInput) {
options2.validateInput = (value) => null;
}
pattern = await window.showInputBox(options2) || "";
if (!pattern) {
window.showInformationMessage( "You must enter a pattern");
window.showInformationMessage("You must enter a pattern");
return;
}
// Replace with upper case
Expand Down

0 comments on commit b224582

Please sign in to comment.