Skip to content
Merged
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
23 changes: 12 additions & 11 deletions packages/cursorless-vscode/src/ide/vscode/vscodeShowQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ export function vscodeShowQuickPick(
}

if (options?.defaultValue != null) {
quickPick.activeItems = quickPickItems.filter(
const activeItem = quickPickItems.find(
(item) => item.value === options.defaultValue,
);
if (activeItem != null) {
quickPick.activeItems = [activeItem];
}
}

if (options?.unknownValues) {
Expand All @@ -45,19 +48,17 @@ export function vscodeShowQuickPick(
: "Add new value '{}' →";

quickPick.onDidChangeValue(() => {
quickPick.items = [
...quickPickItems,

// INJECT user values into proposed values
...(items.includes(quickPick.value) || quickPick.value.trim() === ""
? []
const value = quickPick.value.trim();
quickPick.items =
value === "" || items.includes(value)
? quickPickItems
: [
...quickPickItems,
{
label: newValueTemplate.replace("{}", quickPick.value),
value: quickPick.value,
label: newValueTemplate.replace("{}", value),
value,
},
]),
];
];
});
}

Expand Down
Loading