Skip to content

Commit

Permalink
防止重入
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Mar 28, 2024
1 parent acfa03a commit 5a3d8ff
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as vscode from 'vscode';
import * as os from 'os';
import winreg from 'winreg';
import path from 'path';
import util from 'util';
import * as tools from './tools';
import { isFileValid, isPathValid, randomInt } from './utility';
import * as fs from 'fs';
Expand All @@ -21,6 +22,23 @@ let defaultTableTypeToCSVfolderPath: Readonly<{ [key: string]: string }> = {
sound: "./resource/editor_table/声音"
};

function reReady(method: Function, context: ClassMethodDecoratorContext) {
let running = false;
return async function (this: any, ...args: any[]) {
if (running) {
while (running) {
await util.promisify(setTimeout)(100);
}
}
running = true;
try {
await method.apply(this, args);
} finally {
running = false;
}
};
}

class EnvPath {

private async searchEditorUriByReg(): Promise<vscode.Uri | undefined> {
Expand Down Expand Up @@ -239,6 +257,7 @@ class EnvPath {
}
}

@reReady
public async editorReady(askUser = false) {
if (this.editorUri) {
return;
Expand All @@ -251,6 +270,7 @@ class EnvPath {
tools.log.info(`editorVersion: ${this.editorVersion}`);
}

@reReady
public async mapReady(askUser = false) {
if (this.mapUri) {
return;
Expand Down

0 comments on commit 5a3d8ff

Please sign in to comment.