소스 검색

Fix errors with run script
Fix build error on linux

geequlim 8 년 전
부모
커밋
749148841d
2개의 변경된 파일27개의 추가작업 그리고 17개의 파일을 삭제
  1. 12 12
      package.json
  2. 15 5
      src/tool_manager.ts

+ 12 - 12
package.json

@@ -20,7 +20,7 @@
   ],
   "main": "./out/src/extension",
   "contributes": {
-    "commands":[
+    "commands": [
       {
         "command": "godot.updateWorkspaceSymbols",
         "title": "GodotTools: Update Workspace Symbols"
@@ -68,19 +68,19 @@
           "description": "The godot version of your project"
         },
         "GodotTools.parseTextScene": {
-            "type": "boolean",
-            "default": true,
-            "description": "Parse scene files with extention ends with tscn"
+          "type": "boolean",
+          "default": true,
+          "description": "Parse scene files with extention ends with tscn"
         },
         "GodotTools.completeNodePath": {
-            "type": "boolean",
-            "default": false,
-            "description": "Show node pathes of of workspace in the code completion"
+          "type": "boolean",
+          "default": false,
+          "description": "Show node pathes of of workspace in the code completion"
         },
         "GodotTools.godotProjectRoot": {
-            "type": "string",
-            "default": "",
-            "description": "Relate path to the godot project"
+          "type": "string",
+          "default": "",
+          "description": "Relate path to the godot project"
         }
       }
     },
@@ -121,7 +121,7 @@
   },
   "scripts": {
     "vscode:prepublish": "tsc -p ./",
-    "compile": "tsc -watch -p ./",
+    "compile": "node ./node_modules/typescript/bin/tsc -p ./",
     "postinstall": "node ./node_modules/vscode/bin/install",
     "test": "node ./node_modules/vscode/bin/test"
   },
@@ -135,6 +135,6 @@
   "dependencies": {
     "glob": "^7.1.1",
     "vscode-debugprotocol": "^1.17.0",
-		"vscode-debugadapter": "^1.17.0"
+    "vscode-debugadapter": "^1.17.0"
   }
 }

+ 15 - 5
src/tool_manager.ts

@@ -198,15 +198,25 @@ class ToolManager {
   }
 
   private runCurrentScene() {
+    const absFilePath = vscode.window.activeTextEditor.document.uri.fsPath;
     let scenePath = null
-    if (vscode.window.activeTextEditor)
-      scenePath = path.relative(this._rootDir, vscode.window.activeTextEditor.document.uri.fsPath);
+    if (vscode.window.activeTextEditor) {
+      scenePath = path.relative(this._rootDir, absFilePath);
       scenePath = scenePath.replace(/\\/g, "/");
+    }
+    // Run scripts directly which is inhired from SceneTree or MainLoop
     if (scenePath.endsWith(".gd")) {
       const scriptPath = scenePath;
       scenePath = config.scriptSceneMap[config.normalizePath(scenePath)];
-      if (!scenePath && vscode.window.activeTextEditor.document.getText().match(/\s+extends SceneTree\s/g))
-        scenePath = scriptPath;
+      if (!scenePath) {
+        const script = config.loadSymbolsFromFile(absFilePath);
+        if (script) {
+          if(script.native == "SceneTree" || script.native == "MainLoop") {
+            this.runEditor(`-s ${scriptPath}`);
+            return;
+          }
+        }
+      }
     }
     if (scenePath) {
       if (scenePath.endsWith(".gd"))
@@ -215,7 +225,7 @@ class ToolManager {
         scenePath = ` res://${scenePath} `;
       this.openWorkspaceWithEditor(scenePath);
     } else
-      vscode.window.showErrorMessage("Current document is not a scene file");
+      vscode.window.showErrorMessage("Current document is not a scene file or MainLoop");
   }
 
   loadClasses() {