@@ -6,15 +6,19 @@ import { ncp } from 'ncp';
6
6
import { Stats } from 'fs' ;
7
7
import * as fs from './fs-extra' ;
8
8
import URI from '@theia/core/lib/common/uri' ;
9
+ import { isWindows } from '@theia/core/lib/common/os' ;
9
10
import { FileUri , BackendApplicationContribution } from '@theia/core/lib/node' ;
10
11
import { ConfigService } from '../common/protocol/config-service' ;
11
12
import { SketchesService , Sketch } from '../common/protocol/sketches-service' ;
13
+ import { firstToLowerCase } from '../common/utils' ;
12
14
13
15
14
16
// As currently implemented on Linux,
15
17
// the maximum number of symbolic links that will be followed while resolving a pathname is 40
16
18
const MAX_FILESYSTEM_DEPTH = 40 ;
17
19
20
+ const WIN32_DRIVE_REGEXP = / ^ [ a - z A - Z ] : \\ / ;
21
+
18
22
// TODO: `fs`: use async API
19
23
@injectable ( )
20
24
export class SketchesServiceImpl implements SketchesService , BackendApplicationContribution {
@@ -330,8 +334,19 @@ void loop() {
330
334
}
331
335
332
336
async isTemp ( sketch : Sketch ) : Promise < boolean > {
333
- const sketchPath = FileUri . fsPath ( sketch . uri ) ;
334
- return sketchPath . indexOf ( '.arduinoProIDE-unsaved' ) !== - 1 && sketchPath . startsWith ( os . tmpdir ( ) ) ;
337
+ let sketchPath = FileUri . fsPath ( sketch . uri ) ;
338
+ let temp = os . tmpdir ( ) ;
339
+ // Note: VS Code URI normalizes the drive letter. `C:` will be converted into `c:`.
340
+ // https://github.com/Microsoft/vscode/issues/68325#issuecomment-462239992
341
+ if ( isWindows ) {
342
+ if ( WIN32_DRIVE_REGEXP . exec ( sketchPath ) ) {
343
+ sketchPath = firstToLowerCase ( sketchPath ) ;
344
+ }
345
+ if ( WIN32_DRIVE_REGEXP . exec ( temp ) ) {
346
+ temp = firstToLowerCase ( temp ) ;
347
+ }
348
+ }
349
+ return sketchPath . indexOf ( '.arduinoProIDE-unsaved' ) !== - 1 && sketchPath . startsWith ( temp ) ;
335
350
}
336
351
337
352
async copy ( sketch : Sketch , { destinationUri } : { destinationUri : string } ) : Promise < string > {
0 commit comments