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(); }