From 5a3d8ffb01556498f7404e3f1c1a3ed09508507e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 28 Mar 2024 18:27:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E9=87=8D=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/env.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/env.ts b/src/env.ts index bbaeaeb..8fe9803 100644 --- a/src/env.ts +++ b/src/env.ts @@ -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'; @@ -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 { @@ -239,6 +257,7 @@ class EnvPath { } } + @reReady public async editorReady(askUser = false) { if (this.editorUri) { return; @@ -251,6 +270,7 @@ class EnvPath { tools.log.info(`editorVersion: ${this.editorVersion}`); } + @reReady public async mapReady(askUser = false) { if (this.mapUri) { return;