File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
packages/app/src/app/overmind/effects/vscode Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -310,16 +310,24 @@ export class VSCodeEffect {
310310 public async openModule ( module : Module ) {
311311 await this . initialized ;
312312
313- try {
314- const model = await this . modelsHandler . changeModule ( module ) ;
315-
316- this . lint ( module . title , model ) ;
317- } catch ( error ) {
318- // We might try to open a module that is not actually opened in the editor,
319- // but the configuration wizard.. currently this throws an error as there
320- // is really no good way to identify when it happen. This needs to be
321- // improved in next version
322- }
313+ // We use an animation frame here, because we want the rest of the logic to finish running,
314+ // allowing for a paint, like selections in explorer. For this to work we have to ensure
315+ // that we are actually indeed still trying to open this file, as we might have changed
316+ // the file
317+ requestAnimationFrame ( async ( ) => {
318+ if ( module . id === this . options . getCurrentModule ( ) . id ) {
319+ try {
320+ const model = await this . modelsHandler . changeModule ( module ) ;
321+
322+ this . lint ( module . title , model ) ;
323+ } catch ( error ) {
324+ // We might try to open a module that is not actually opened in the editor,
325+ // but the configuration wizard.. currently this throws an error as there
326+ // is really no good way to identify when it happen. This needs to be
327+ // improved in next version
328+ }
329+ }
330+ } ) ;
323331 }
324332
325333 setErrors = ( errors : ModuleError [ ] ) => {
You can’t perform that action at this time.
0 commit comments