@@ -16,7 +16,7 @@ import { normalize, sep } from 'path';
1616
1717import * as ts from 'typescript' ;
1818import { getSemanticTokens , getSemanticTokenLegend } from './javascriptSemanticTokens' ;
19- import { RequestService } from '../requests' ;
19+ import { FileSystemProvider } from '../requests' ;
2020import { NodeRequestService } from '../node/nodeFs' ;
2121
2222const JS_WORD_REGEX = / ( - ? \d * \. \d \w * ) | ( [ ^ \` \~ \! \@ \# \% \^ \& \* \( \) \- \= \+ \[ \{ \] \} \\ \| \; \: \' \" \, \. \< \> \/ \? \s ] + ) / g;
@@ -33,7 +33,7 @@ function deschemeURI(uri: string) {
3333 // Both \ and / must be escaped in regular expressions
3434 newPath = newPath . replace ( new RegExp ( '\\' + sep , 'g' ) , '/' ) ;
3535
36- if ( process . platform !== 'win32' ) return newPath ;
36+ if ( process . platform !== 'win32' ) { return newPath ; }
3737
3838 // Windows URIs come in like '/c%3A/Users/orta/dev/...', we need to switch it to 'c:/Users/orta/dev/...'
3939 return newPath . slice ( 1 ) . replace ( '%3A' , ':' ) ;
@@ -104,7 +104,9 @@ function getLanguageServiceHost(scriptKind: ts.ScriptKind, fs: NodeRequestServic
104104 return {
105105 async getLanguageService ( jsDocument : TextDocument , workspace : Workspace ) : Promise < ts . LanguageService > {
106106 currentTextDocument = jsDocument ;
107- if ( workspace . folders . find ( f => f . uri . startsWith ( 'file://' ) ) ) currentWorkspace = workspace ;
107+ if ( workspace . folders . find ( f => f . uri . startsWith ( 'file://' ) || f . uri . startsWith ( '/' ) || f . uri . startsWith ( '\\' ) ) ) {
108+ currentWorkspace = workspace ;
109+ }
108110 return jsLanguageService ;
109111 } ,
110112 getCompilationSettings ( ) {
@@ -117,7 +119,7 @@ function getLanguageServiceHost(scriptKind: ts.ScriptKind, fs: NodeRequestServic
117119}
118120
119121
120- export function getJavaScriptMode ( documentRegions : LanguageModelCache < HTMLDocumentRegions > , languageId : 'javascript' | 'typescript' , workspace : Workspace , fs : RequestService ) : LanguageMode {
122+ export function getJavaScriptMode ( documentRegions : LanguageModelCache < HTMLDocumentRegions > , languageId : 'javascript' | 'typescript' , workspace : Workspace , fs : FileSystemProvider ) : LanguageMode {
121123 let jsDocuments = getLanguageModelCache < TextDocument > ( 10 , 60 , document => documentRegions . get ( document ) . getEmbeddedDocument ( languageId ) ) ;
122124
123125 const host = getLanguageServiceHost ( languageId === 'javascript' ? ts . ScriptKind . JS : ts . ScriptKind . TS , fs as NodeRequestService ) ;
0 commit comments