mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
Fix errors on windows
This commit is contained in:
@@ -30,6 +30,18 @@ class Config {
|
||||
getAllSymbols() {
|
||||
return this.symbols;
|
||||
}
|
||||
|
||||
normalizePath(path) {
|
||||
let newpath = path;
|
||||
if( path.indexOf(":") != -1){
|
||||
let parts = path.split(":");
|
||||
newpath = parts[0].toUpperCase()
|
||||
for(let i=1; i<parts.length; i++)
|
||||
newpath += parts[i].replace(/\\/g, "/");
|
||||
}
|
||||
return newpath;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export default new Config();
|
||||
@@ -3,6 +3,7 @@ import * as fs from 'fs';
|
||||
import requestGodot from './request';
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import config from './config';
|
||||
|
||||
let version: string;
|
||||
let storageDir: string;
|
||||
@@ -63,7 +64,7 @@ class DocDataManager {
|
||||
if(fs.existsSync(docfile) && fs.statSync(docfile).isFile())
|
||||
loadDocdata(docfile);
|
||||
else {
|
||||
requestGodot({action: "editor", command: "gendoc", path: docfile}).then((res:any)=>{
|
||||
requestGodot({action: "editor", command: "gendoc", path: config.normalizePath(docfile) }).then((res:any)=>{
|
||||
if(res && res.done)
|
||||
loadDocdata(docfile);
|
||||
else
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
} from 'vscode';
|
||||
|
||||
import requestGodot from '../request';
|
||||
import config from '../config';
|
||||
|
||||
interface CompleteRequest {
|
||||
path: string,
|
||||
@@ -36,7 +37,7 @@ class GDScriptCompletionItemProvider implements CompletionItemProvider {
|
||||
provideCompletionItems(document : TextDocument, position : Position, token : CancellationToken) : CompletionItem[] | Thenable < CompletionItem[] > | CompletionList | Thenable < CompletionList > {
|
||||
// console.log("[GodotTools]:provideCompletionItems");
|
||||
const request: CompleteRequest = {
|
||||
path: document.fileName,
|
||||
path: config.normalizePath(document.fileName),
|
||||
text: document.getText(),
|
||||
cursor: {
|
||||
row: position.line + 1,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import requestGodot from "../request";
|
||||
import * as vscode from 'vscode';
|
||||
import {DiagnosticCollection, DiagnosticSeverity} from 'vscode';
|
||||
import config from '../config';
|
||||
|
||||
interface GDParseError {
|
||||
message: string,
|
||||
column: number,
|
||||
@@ -72,7 +74,7 @@ class GDScriptDiagnosticSeverity {
|
||||
if(doc.languageId == 'gdscript') {
|
||||
// console.log('[GodotTools]:start parsing document ', doc);
|
||||
const self = this;
|
||||
const request: ParseRequest = {text: doc.getText(), path: doc.fileName};
|
||||
const request: ParseRequest = {text: doc.getText(), path: config.normalizePath(doc.fileName)};
|
||||
requestGodot({action: "parsescript",request}).then((data: any)=>{
|
||||
const result: GDScript = data.result;
|
||||
if(result && vscode.window.activeTextEditor.document == doc){
|
||||
|
||||
@@ -14,10 +14,9 @@ class ToolManager {
|
||||
private workspacesymbolprovider: GDScriptWorkspaceSymbolProvider = null;
|
||||
|
||||
constructor(context: vscode.ExtensionContext) {
|
||||
this.workspaceDir = vscode.workspace.rootPath;
|
||||
this.workspaceDir = vscode.workspace.rootPath.replace(/\\/g, "/");
|
||||
this.validate();
|
||||
this.loadWorkspaceSymbols();
|
||||
|
||||
this.docs = new DocDataManager(context.extensionPath);
|
||||
this.symbolprovider = new GDScriptSymbolProvider();
|
||||
vscode.languages.registerDocumentSymbolProvider('gdscript', this.symbolprovider);
|
||||
@@ -32,7 +31,7 @@ class ToolManager {
|
||||
let path = res.path;
|
||||
if(path && path.length> 0 && path.endsWith("/"))
|
||||
path = path.substring(0, path.length-1)
|
||||
if( path == self.workspaceDir)
|
||||
if( path.toLowerCase() == self.workspaceDir.toLowerCase())
|
||||
vscode.window.showInformationMessage("Connected to godot editor server");
|
||||
else {
|
||||
vscode.window.showWarningMessage("The opened project is not same with godot editor");
|
||||
|
||||
Reference in New Issue
Block a user