From a8d13181581a6dca26a8ff44d3bebda7167f4611 Mon Sep 17 00:00:00 2001 From: terwer Date: Mon, 24 Mar 2025 11:22:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#24=20mac=20=E7=94=B5=E8=84=91=E7=9A=84?= =?UTF-8?q?=20vscode=20=E6=8F=92=E4=BB=B6AutoJs6=20VSCode=20Extension?= =?UTF-8?q?=EF=BC=8C=E8=BF=90=E8=A1=8C=E9=A1=B9=E7=9B=AE=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extension.ts | 4 ++-- src/project.ts | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 3356874..acbc575 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1431,11 +1431,11 @@ export class Extension { } runProject(url?: string) { - this.sendProjectCommand('run_project', url); + this.sendProjectCommand('run_project', undefined); } saveProject(url?: string) { - this.sendProjectCommand('save_project', url); + this.sendProjectCommand('save_project', undefined); } commandsHierarchy() { diff --git a/src/project.ts b/src/project.ts index a720ffb..f91cd3e 100644 --- a/src/project.ts +++ b/src/project.ts @@ -58,7 +58,8 @@ export class Project { constructor(folder: Uri) { this.folder = folder; - let projectPath = path.join(this.folder.fsPath, 'project.json'); + const basePath = this.getBasePath(); + let projectPath = path.join(basePath, 'project.json'); if (!fs.existsSync(projectPath)) { vscode.window.showErrorMessage(`缺少必要的项目配置文件: ${projectPath}`); return Object.create(null); @@ -78,11 +79,21 @@ export class Project { // noinspection JSUnusedLocalSymbols fileFilter(relativePath: string, absPath: string, stats: fs.Stats) { return this.config.ignore.filter((p) => { - const fullPath = path.join(this.folder.fsPath, p); + const basePath = this.getBasePath(); + const fullPath = path.join(basePath, p); return absPath.startsWith(fullPath); }).length === 0; }; + getBasePath() { + let basePath = this.folder.fsPath + const stats = fs.statSync(this.folder.fsPath); + if (stats.isFile()) { + basePath = path.dirname(this.folder.fsPath) + } + return basePath + } + dispose() { this.watcher.dispose(); }