Skip to content

Commit 4de776f

Browse files
committed
Replace back button with close button in file browser when opened from empty context and fix button handling flow
1 parent 255147d commit 4de776f

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

packages/vscode/src/views/panel/backend/message-handlers/handle-at-sign-quick-pick/handle-at-sign-quick-pick.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,19 @@ const add_to_context_if_needed = async (
2626
const browse_all_files = async (
2727
workspace_provider: WorkspaceProvider,
2828
workspace_roots: string[],
29-
format_path: (p: string) => string
29+
format_path: (p: string) => string,
30+
show_back_button: boolean = true
3031
): Promise<QuickPickItem | 'back' | undefined> => {
3132
const quick_pick = vscode.window.createQuickPick<QuickPickItem>()
3233
quick_pick.placeholder = 'Select a file'
3334
quick_pick.title = 'All Files'
34-
quick_pick.buttons = [vscode.QuickInputButtons.Back]
35+
if (show_back_button) {
36+
quick_pick.buttons = [vscode.QuickInputButtons.Back]
37+
} else {
38+
quick_pick.buttons = [
39+
{ iconPath: new vscode.ThemeIcon('close'), tooltip: 'Close' }
40+
]
41+
}
3542
quick_pick.matchOnDescription = true
3643
quick_pick.busy = true
3744
quick_pick.show()
@@ -72,8 +79,8 @@ const browse_all_files = async (
7279
quick_pick.onDidTriggerButton((button) => {
7380
if (button === vscode.QuickInputButtons.Back) {
7481
resolve('back')
75-
quick_pick.hide()
7682
}
83+
quick_pick.hide()
7784
})
7885

7986
quick_pick.onDidAccept(() => {
@@ -112,7 +119,8 @@ const at_sign_quick_pick = async (params: {
112119
const browsed_item = await browse_all_files(
113120
params.workspace_provider,
114121
workspace_roots,
115-
format_path
122+
format_path,
123+
false
116124
)
117125
if (browsed_item && browsed_item !== 'back') {
118126
await add_to_context_if_needed(
@@ -222,7 +230,8 @@ const at_sign_quick_pick = async (params: {
222230
const browsed_item = await browse_all_files(
223231
params.workspace_provider,
224232
workspace_roots,
225-
format_path
233+
format_path,
234+
true
226235
)
227236
if (browsed_item === 'back') {
228237
continue // Go back to the main quick pick

0 commit comments

Comments
 (0)