Skip to content

Commit

Permalink
wait to avoid race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellourbani committed Oct 21, 2023
1 parent d4fa4b2 commit f997d2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@
},
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.tsc.autoDetect": "off",
"npm.exclude": ["**/client", "**/server"]
"npm.exclude": [
"**/client",
"**/server"
],
"files.watcherExclude": {
"**/node_modules/*/**": false,
"**/node_modules/[!@]*/**/*": true
}
}
8 changes: 7 additions & 1 deletion client/src/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,21 @@ export class Flows {
const path = editor.document.uri.path.replace(/\.[^\.]*/, "").replace(/.*\//, "");
const uri = vscode.Uri.parse(`${ABAPLINTSCHEME}:${path}.dot`);
setDocument(uri, "Loading");
const startTime = new Date().getTime();
const doc = await vscode.workspace.openTextDocument(uri);
await vscode.window.showTextDocument(doc, {preview: false, viewColumn: vscode.ViewColumn.Beside});

if (this.pending) {
await this.pending;
}
this.pending = new Promise((resolve) => {
this.emitter.event((content) => {
const disposable = this.emitter.event(async (content) => {
disposable.dispose();
const contents = JSON.parse(content).join("\n\n");
const dt = new Date().getTime() - startTime;
if (dt < 500) {
await new Promise((resolve) => setTimeout(resolve, 500 - dt));
}
setDocument(uri, contents);
this.pending = undefined;
resolve();
Expand Down

0 comments on commit f997d2c

Please sign in to comment.