Skip to content

Commit 31662e6

Browse files
committed
Hide preset reordering buttons in the Quick Pick when a search query is active
1 parent 706ae13 commit 31662e6

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

packages/ui/src/components/editor/Dropdown/Dropdown.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
border: 1px solid var(--vscode-dropdown-border);
1212
border-radius: var(--border-radius-4px);
1313
cursor: pointer;
14-
color: var(--vscode-dropdown-foreground);
14+
color: var(--vscode-foreground);
1515
width: 100%;
1616

1717
&--open {

packages/vscode/src/view/backend/message-handlers/handle-send-prompt.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ async function validate_presets(params: {
212212
tooltip: 'Move down'
213213
}
214214

215+
const quick_pick = vscode.window.createQuickPick<
216+
vscode.QuickPickItem & { name: string; index: number }
217+
>()
218+
215219
const create_items = () => {
216220
return presets.map((preset, index) => {
217221
const is_unnamed = !preset.name || /^\(\d+\)$/.test(preset.name.trim())
@@ -221,7 +225,8 @@ async function validate_presets(params: {
221225
: ''
222226

223227
const buttons = []
224-
if (presets.length > 1) {
228+
// Only show move buttons when not searching and there's more than one preset
229+
if (!quick_pick.value && presets.length > 1) {
225230
if (index > 0) buttons.push(move_up_button)
226231
if (index < presets.length - 1) buttons.push(move_down_button)
227232
}
@@ -238,16 +243,14 @@ async function validate_presets(params: {
238243
})
239244
}
240245

241-
const quick_pick = vscode.window.createQuickPick<
242-
vscode.QuickPickItem & { name: string; index: number }
243-
>()
244-
const items = create_items()
245-
quick_pick.items = items
246+
quick_pick.items = create_items()
246247
quick_pick.placeholder = 'Select preset'
247248
quick_pick.matchOnDescription = true
248249

249250
if (last_selected_item) {
250-
const last_item = items.find((item) => item.name == last_selected_item)
251+
const last_item = quick_pick.items.find(
252+
(item) => item.name == last_selected_item
253+
)
251254
if (last_item) {
252255
quick_pick.activeItems = [last_item]
253256
}
@@ -257,11 +260,16 @@ async function validate_presets(params: {
257260
const disposables: vscode.Disposable[] = []
258261

259262
disposables.push(
263+
quick_pick.onDidChangeValue(() => {
264+
// Refresh items when search value changes to show/hide move buttons
265+
quick_pick.items = create_items()
266+
}),
260267
quick_pick.onDidTriggerItemButton(async (event) => {
261268
const item = event.item as vscode.QuickPickItem & {
262269
name: string
263270
index: number
264271
}
272+
265273
if (event.button === move_up_button) {
266274
if (item.index > 0) {
267275
const temp = presets[item.index - 1]
@@ -311,6 +319,7 @@ async function validate_presets(params: {
311319
quick_pick.dispose()
312320
resolve([])
313321
})
322+
314323
disposables.push(quick_pick)
315324
quick_pick.show()
316325
})

0 commit comments

Comments
 (0)