@@ -105,55 +105,57 @@ export class PathExecutableCache implements vscode.Disposable {
105
105
const result = new Set < ICompletionResource > ( ) ;
106
106
const fileResource = vscode . Uri . file ( path ) ;
107
107
const files = await vscode . workspace . fs . readDirectory ( fileResource ) ;
108
- for ( const [ file , fileType ] of files ) {
109
- let kind : vscode . TerminalCompletionItemKind | undefined ;
110
- let formattedPath : string | undefined ;
111
- const resource = vscode . Uri . joinPath ( fileResource , file ) ;
112
-
113
- // Skip unknown or directory file types early
114
- if ( fileType === vscode . FileType . Unknown || fileType === vscode . FileType . Directory ) {
115
- continue ;
116
- }
108
+ await Promise . all (
109
+ files . map ( ( [ file , fileType ] ) => ( async ( ) => {
110
+ let kind : vscode . TerminalCompletionItemKind | undefined ;
111
+ let formattedPath : string | undefined ;
112
+ const resource = vscode . Uri . joinPath ( fileResource , file ) ;
113
+
114
+ // Skip unknown or directory file types early
115
+ if ( fileType === vscode . FileType . Unknown || fileType === vscode . FileType . Directory ) {
116
+ return ;
117
+ }
117
118
118
- try {
119
- const lstat = await fs . lstat ( resource . fsPath ) ;
120
- if ( lstat . isSymbolicLink ( ) ) {
121
- try {
122
- const symlinkRealPath = await fs . realpath ( resource . fsPath ) ;
123
- const isExec = await isExecutable ( symlinkRealPath , this . _cachedWindowsExeExtensions ) ;
124
- if ( ! isExec ) {
125
- continue ;
119
+ try {
120
+ const lstat = await fs . lstat ( resource . fsPath ) ;
121
+ if ( lstat . isSymbolicLink ( ) ) {
122
+ try {
123
+ const symlinkRealPath = await fs . realpath ( resource . fsPath ) ;
124
+ const isExec = await isExecutable ( symlinkRealPath , this . _cachedWindowsExeExtensions ) ;
125
+ if ( ! isExec ) {
126
+ return ;
127
+ }
128
+ kind = vscode . TerminalCompletionItemKind . Method ;
129
+ formattedPath = `${ resource . fsPath } -> ${ symlinkRealPath } ` ;
130
+ } catch {
131
+ return ;
126
132
}
127
- kind = vscode . TerminalCompletionItemKind . Method ;
128
- formattedPath = `${ resource . fsPath } -> ${ symlinkRealPath } ` ;
129
- } catch {
130
- continue ;
131
133
}
134
+ } catch {
135
+ // Ignore errors for unreadable files
136
+ return ;
132
137
}
133
- } catch {
134
- // Ignore errors for unreadable files
135
- continue ;
136
- }
137
138
138
- formattedPath = formattedPath ?? getFriendlyResourcePath ( resource , pathSeparator ) ;
139
+ formattedPath = formattedPath ?? getFriendlyResourcePath ( resource , pathSeparator ) ;
139
140
140
- // Check if already added or not executable
141
- if ( labels . has ( file ) ) {
142
- continue ;
143
- }
141
+ // Check if already added or not executable
142
+ if ( labels . has ( file ) ) {
143
+ return ;
144
+ }
144
145
145
- const isExec = kind === vscode . TerminalCompletionItemKind . Method || await isExecutable ( formattedPath , this . _cachedWindowsExeExtensions ) ;
146
- if ( ! isExec ) {
147
- continue ;
148
- }
146
+ const isExec = kind === vscode . TerminalCompletionItemKind . Method || await isExecutable ( formattedPath , this . _cachedWindowsExeExtensions ) ;
147
+ if ( ! isExec ) {
148
+ return ;
149
+ }
149
150
150
- result . add ( {
151
- label : file ,
152
- documentation : formattedPath ,
153
- kind : kind ?? vscode . TerminalCompletionItemKind . Method
154
- } ) ;
155
- labels . add ( file ) ;
156
- }
151
+ result . add ( {
152
+ label : file ,
153
+ documentation : formattedPath ,
154
+ kind : kind ?? vscode . TerminalCompletionItemKind . Method
155
+ } ) ;
156
+ labels . add ( file ) ;
157
+ } ) ( ) )
158
+ ) ;
157
159
return result ;
158
160
} catch ( e ) {
159
161
// Ignore errors for directories that can't be read
0 commit comments