1+ import fs from 'fs'
12import { ViewProvider } from '@/views/panel/backend/panel-provider'
23import { HOME_VIEW_TYPES } from '@/views/panel/types/home-view-type'
34import * as vscode from 'vscode'
@@ -16,31 +17,48 @@ const at_sign_quick_pick = async (params: {
1617
1718 const workspace_roots = params . workspace_provider . getWorkspaceRoots ( )
1819
19- const quick_pick_items = checked_paths . map ( ( p ) => {
20- let relative_path = p
21- const root = params . workspace_provider . get_workspace_root_for_file ( p )
22- if ( root ) {
23- if ( workspace_roots . length > 1 ) {
24- const ws_name = params . workspace_provider . get_workspace_name ( root )
25- relative_path = path . join ( ws_name , path . relative ( root , p ) )
26- } else {
27- relative_path = path . relative ( root , p )
20+ const quick_pick_items = checked_paths
21+ . filter ( ( p ) => {
22+ try {
23+ return fs . existsSync ( p ) && fs . statSync ( p ) . isFile ( )
24+ } catch {
25+ return false
2826 }
29- }
30- return { label : relative_path . replace ( / \\ / g, '/' ) }
31- } )
27+ } )
28+ . map ( ( p ) => {
29+ let relative_path = p
30+ const root = params . workspace_provider . get_workspace_root_for_file ( p )
31+ if ( root ) {
32+ if ( workspace_roots . length > 1 ) {
33+ const ws_name = params . workspace_provider . get_workspace_name ( root )
34+ relative_path = path . join ( ws_name , path . relative ( root , p ) )
35+ } else {
36+ relative_path = path . relative ( root , p )
37+ }
38+ }
39+ const normalized_path = relative_path . replace ( / \\ / g, '/' )
40+ const filename = path . basename ( normalized_path )
41+ const dir_path = path . dirname ( normalized_path )
42+
43+ return {
44+ label : filename ,
45+ description : dir_path === '.' ? '' : dir_path ,
46+ fullPath : normalized_path
47+ }
48+ } )
3249
33- quick_pick_items . sort ( ( a , b ) => natural_sort ( a . label , b . label ) )
50+ quick_pick_items . sort ( ( a , b ) => natural_sort ( a . fullPath , b . fullPath ) )
3451
3552 const selected_path_item = await vscode . window . showQuickPick (
3653 quick_pick_items ,
3754 {
38- placeHolder : 'Select a path to place in the input field'
55+ placeHolder : 'Select a path to place in the input field' ,
56+ matchOnDescription : true
3957 }
4058 )
4159
4260 if ( selected_path_item ) {
43- return `\`${ selected_path_item . label } \` `
61+ return `\`${ selected_path_item . fullPath } \` `
4462 }
4563 return
4664}
0 commit comments