@@ -122,10 +122,29 @@ What do you want to do?`,
122122 } ) ;
123123}
124124
125- function updateOthers ( others : string [ ] ) {
125+ function updateOthers ( others : string [ ] , baseUri : vscode . Uri ) {
126+ let workspaceFolder = vscode . workspace . getWorkspaceFolder ( baseUri ) ;
127+ if ( ! workspaceFolder && ( baseUri . scheme === FILESYSTEM_SCHEMA || baseUri . scheme === FILESYSTEM_READONLY_SCHEMA ) ) {
128+ // hack to deal with problem seen with isfs* schemes
129+ workspaceFolder = vscode . workspace . getWorkspaceFolder ( baseUri . with ( { path : "" } ) ) ;
130+ }
131+ const workspaceFolderName = workspaceFolder ? workspaceFolder . name : "" ;
126132 others . forEach ( ( item ) => {
127- const uri = DocumentContentProvider . getUri ( item ) ;
128- documentContentProvider . update ( uri ) ;
133+ const uri = DocumentContentProvider . getUri ( item , workspaceFolderName ) ;
134+ if ( uri . scheme === FILESYSTEM_SCHEMA || uri . scheme === FILESYSTEM_READONLY_SCHEMA ) {
135+ // Massage uri.path to change the first N-1 dots to slashes, where N is the number of slashes in baseUri.path
136+ // For example, when baseUri.path is /Foo/Bar.cls and uri.path is /Foo.Bar.1.int
137+ const partsToConvert = baseUri . path . split ( "/" ) . length - 1 ;
138+ const dotParts = uri . path . split ( "." ) ;
139+ const correctPath =
140+ dotParts . length <= partsToConvert
141+ ? uri . path
142+ : dotParts . slice ( 0 , partsToConvert ) . join ( "/" ) + "." + dotParts . slice ( partsToConvert ) . join ( "." ) ;
143+ console . log ( `updateOthers: uri.path=${ uri . path } baseUri.path=${ baseUri . path } correctPath=${ correctPath } ` ) ;
144+ fileSystemProvider . fireFileChanged ( uri . with ( { path : correctPath } ) ) ;
145+ } else {
146+ documentContentProvider . update ( uri ) ;
147+ }
129148 } ) ;
130149}
131150
@@ -145,15 +164,14 @@ export async function loadChanges(files: CurrentFile[]): Promise<any> {
145164 if ( file . uri . scheme === "file" ) {
146165 fs . writeFileSync ( file . fileName , content ) ;
147166 } else if ( file . uri . scheme === FILESYSTEM_SCHEMA || file . uri . scheme === FILESYSTEM_READONLY_SCHEMA ) {
148- fileSystemProvider . writeFile ( file . uri , Buffer . from ( content ) , {
149- overwrite : true ,
150- create : false ,
151- } ) ;
167+ fileSystemProvider . fireFileChanged ( file . uri ) ;
152168 }
153169 } )
154170 . then ( ( ) => api . actionIndex ( [ file . name ] ) )
155171 . then ( ( data ) => data . result . content [ 0 ] . others )
156- . then ( updateOthers )
172+ . then ( ( others ) => {
173+ updateOthers ( others , file . uri ) ;
174+ } )
157175 )
158176 ) ;
159177}
@@ -191,13 +209,14 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
191209 outputChannel . show ( true ) ;
192210 } ) ;
193211 }
194- return [ ] ;
212+ // Even when compile failed we should still fetch server changes
213+ return docs ;
195214 } )
196215 )
197216 . then ( loadChanges ) ;
198217}
199218
200- export async function importAndCompile ( askFLags = false , document ?: vscode . TextDocument ) : Promise < any > {
219+ export async function importAndCompile ( askFlags = false , document ?: vscode . TextDocument ) : Promise < any > {
201220 const file = currentFile ( document ) ;
202221 if ( ! file ) {
203222 return ;
@@ -209,7 +228,7 @@ export async function importAndCompile(askFLags = false, document?: vscode.TextD
209228 }
210229
211230 const defaultFlags = config ( ) . compileFlags ;
212- const flags = askFLags ? await compileFlags ( ) : defaultFlags ;
231+ const flags = askFlags ? await compileFlags ( ) : defaultFlags ;
213232 return importFile ( file )
214233 . catch ( ( error ) => {
215234 // console.error(error);
0 commit comments