Skip to content

Commit 078c8cc

Browse files
committed
Reorder workspace menu commands and improve workspace file selection QuickPick interaction
- prevent closing the quick pick on outside click (`apps/editor/src/commands/select-workspace-file-command.ts`), though allow when user browse parent folders
1 parent d3d143d commit 078c8cc

2 files changed

Lines changed: 28 additions & 22 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,12 @@
643643
"group": "1_more@2"
644644
},
645645
{
646-
"command": "codeWebChat.selectClipboardPaths",
646+
"command": "codeWebChat.selectWorkspaceFile",
647647
"when": "view == codeWebChatViewWorkspace",
648648
"group": "3_more@1"
649649
},
650650
{
651-
"command": "codeWebChat.selectWorkspaceFile",
651+
"command": "codeWebChat.selectClipboardPaths",
652652
"when": "view == codeWebChatViewWorkspace",
653653
"group": "3_more@2"
654654
},

‎apps/editor/src/commands/select-workspace-file-command.ts‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ export const select_workspace_file_command = (
3636
const selected = await new Promise<vscode.QuickPickItem | undefined>(
3737
(resolve) => {
3838
const quick_pick = vscode.window.createQuickPick()
39-
quick_pick.ignoreFocusOut = true
4039
quick_pick.items = items
4140
quick_pick.placeholder = t(
4241
'command.select-workspace-file.select-workspace'
4342
)
4443
quick_pick.title = t(
4544
'command.select-workspace-file.workspace-folders'
4645
)
46+
quick_pick.ignoreFocusOut = true
4747
quick_pick.buttons = [
4848
{
4949
iconPath: new vscode.ThemeIcon('close'),
@@ -79,11 +79,11 @@ export const select_workspace_file_command = (
7979
}
8080

8181
const quick_pick = vscode.window.createQuickPick<FileQuickPickItem>()
82-
quick_pick.ignoreFocusOut = true
8382
quick_pick.title = t('command.select-workspace-file.workspace-files')
8483
quick_pick.placeholder = t('command.select-workspace-file.select-file')
8584
quick_pick.matchOnDescription = true
8685
quick_pick.value = last_search_query
86+
quick_pick.ignoreFocusOut = true
8787
quick_pick.buttons = [
8888
{
8989
iconPath: new vscode.ThemeIcon('close'),
@@ -146,7 +146,6 @@ export const select_workspace_file_command = (
146146
label: string
147147
full_path: string
148148
}>()
149-
folder_quick_pick.ignoreFocusOut = true
150149
folder_quick_pick.title = t(
151150
'command.select-workspace-file.parent-folders'
152151
)
@@ -157,12 +156,15 @@ export const select_workspace_file_command = (
157156
label: f.label,
158157
full_path: f.full_path
159158
}))
159+
folder_quick_pick.ignoreFocusOut = false
160160
folder_quick_pick.buttons = [vscode.QuickInputButtons.Back]
161161

162162
let folder_accepted = false
163+
let go_back = false
163164

164165
folder_quick_pick.onDidTriggerButton((button) => {
165166
if (button === vscode.QuickInputButtons.Back) {
167+
go_back = true
166168
folder_quick_pick.hide()
167169
}
168170
})
@@ -200,22 +202,26 @@ export const select_workspace_file_command = (
200202
is_showing_folder_quick_pick = false
201203

202204
if (!folder_accepted) {
203-
if (file_items_cache.length > 0) {
204-
quick_pick.items = file_items_cache
205-
}
206-
quick_pick.value = last_search_query
207-
quick_pick.show()
208-
209-
const source_item = last_interacted_path
210-
? file_items_cache.find(
211-
(i) => i.full_path === last_interacted_path
212-
)
213-
: undefined
214-
215-
if (source_item) {
216-
setTimeout(() => {
217-
quick_pick.activeItems = [source_item]
218-
}, 0)
205+
if (go_back) {
206+
if (file_items_cache.length > 0) {
207+
quick_pick.items = file_items_cache
208+
}
209+
quick_pick.value = last_search_query
210+
quick_pick.show()
211+
212+
const source_item = last_interacted_path
213+
? file_items_cache.find(
214+
(i) => i.full_path === last_interacted_path
215+
)
216+
: undefined
217+
218+
if (source_item) {
219+
setTimeout(() => {
220+
quick_pick.activeItems = [source_item]
221+
}, 0)
222+
}
223+
} else {
224+
quick_pick.dispose()
219225
}
220226
}
221227
})
@@ -225,11 +231,11 @@ export const select_workspace_file_command = (
225231
folder_quick_pick.show()
226232
} else if (e.button.iconPath instanceof vscode.ThemeIcon) {
227233
if (e.button.iconPath.id == 'go-to-file') {
234+
quick_pick.activeItems = [item]
228235
await vscode.commands.executeCommand(
229236
'vscode.open',
230237
vscode.Uri.file(item.full_path)
231238
)
232-
quick_pick.hide()
233239
}
234240
}
235241
})

0 commit comments

Comments
 (0)