@@ -56,6 +56,8 @@ const { forNote, safeMessage, safeGet } = require('./sanitize');
5656
5757/** vscode.FileType.Directory (a stable bit of the API). */
5858const DIR = 2 ;
59+ /** vscode.FileType.File. */
60+ const FILE = 1 ;
5961const HOWS = new Set ( [ 'exit' , 'limit' , 'deadline' , 'aborted' , 'error' ] ) ;
6062/** The exit status of a run that did not run to its end, by how it ended. */
6163const EXIT_FOR_HOW = /** @type {Record<string, number> } */ ( { limit : 126 , deadline : 124 , aborted : 130 , error : 1 } ) ;
@@ -1133,19 +1135,22 @@ function createRuntime(deps) {
11331135 function resolve ( p ) { return resolveIn ( currentMounts ( ) , p ) ; }
11341136
11351137 /**
1136- * What is at an engine path: { type: 'file'|'dir', size } - or null when nothing is, when it is in no mount, or when
1137- * the file system did not say in `workers.fsMs` or failed. Never throws and never waits longer: a caller that
1138- * cannot wait that long (a link under the mouse) races its own timer, as the answer is cheap to drop.
1138+ * What is at an engine path: { type: 'file'|'dir'|'other', size } - or null when nothing is, when it is in no mount,
1139+ * or when the file system did not say in `workers.fsMs` or failed. 'other' is what a provider that does not say
1140+ * (FileType.Unknown) or a link to nothing answers: the engine reads it as a file (kindOf), a link is not made to it.
1141+ * Never throws and never waits longer: a caller that cannot wait that long (a link under the mouse) races its own
1142+ * timer, as the answer is cheap to drop.
11391143 * @param {string } p
1140- * @returns {Promise<{ type: 'file'|'dir', size: number } | null> }
1144+ * @returns {Promise<{ type: 'file'|'dir'|'other' , size: number } | null> }
11411145 */
11421146 async function stat ( p ) {
11431147 try {
11441148 const uri = resolve ( p ) ;
11451149 if ( ! uri ) { return null ; }
11461150 const s = await withTimeout ( vscode . workspace . fs . stat ( uri ) , limits . workers . fsMs ) ;
11471151 const size = sizeOf ( s ) ;
1148- return { type : kindOf ( s . type ) , size : size === null ? 0 : size } ;
1152+ const type = ( s . type & DIR ) !== 0 ? 'dir' : ( s . type & FILE ) !== 0 ? 'file' : 'other' ;
1153+ return { type, size : size === null ? 0 : size } ;
11491154 } catch { return null ; }
11501155 }
11511156
0 commit comments