@@ -122,10 +122,29 @@ What do you want to do?`,
122
122
} ) ;
123
123
}
124
124
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 !== "file" ) {
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 : "" ;
126
132
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
+ }
129
148
} ) ;
130
149
}
131
150
@@ -145,15 +164,14 @@ export async function loadChanges(files: CurrentFile[]): Promise<any> {
145
164
if ( file . uri . scheme === "file" ) {
146
165
fs . writeFileSync ( file . fileName , content ) ;
147
166
} 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 ) ;
152
168
}
153
169
} )
154
170
. then ( ( ) => api . actionIndex ( [ file . name ] ) )
155
171
. then ( ( data ) => data . result . content [ 0 ] . others )
156
- . then ( updateOthers )
172
+ . then ( ( others ) => {
173
+ updateOthers ( others , file . uri ) ;
174
+ } )
157
175
)
158
176
) ;
159
177
}
@@ -191,13 +209,14 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
191
209
outputChannel . show ( true ) ;
192
210
} ) ;
193
211
}
194
- return [ ] ;
212
+ // Even when compile failed we should still fetch server changes
213
+ return docs ;
195
214
} )
196
215
)
197
216
. then ( loadChanges ) ;
198
217
}
199
218
200
- export async function importAndCompile ( askFLags = false , document ?: vscode . TextDocument ) : Promise < any > {
219
+ export async function importAndCompile ( askFlags = false , document ?: vscode . TextDocument ) : Promise < any > {
201
220
const file = currentFile ( document ) ;
202
221
if ( ! file ) {
203
222
return ;
@@ -209,7 +228,7 @@ export async function importAndCompile(askFLags = false, document?: vscode.TextD
209
228
}
210
229
211
230
const defaultFlags = config ( ) . compileFlags ;
212
- const flags = askFLags ? await compileFlags ( ) : defaultFlags ;
231
+ const flags = askFlags ? await compileFlags ( ) : defaultFlags ;
213
232
return importFile ( file )
214
233
. catch ( ( error ) => {
215
234
// console.error(error);
0 commit comments