diff --git a/src/utils/index.ts b/src/utils/index.ts index 1fe3898..0552622 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -15,13 +15,13 @@ export function is_debug_mode(): boolean { export async function find_file(file: string): Promise { if (fs.existsSync(file)) { return vscode.Uri.file(file); - } else { - const fileName = path.basename(file); - const results = await vscode.workspace.findFiles("**/" + fileName); - if (results.length == 1) { - return results[0]; - } } + const fileName = path.basename(file); + const results = await vscode.workspace.findFiles(`**/${fileName}`, null); + if (results.length === 1) { + return results[0]; + } + return null; } @@ -38,7 +38,7 @@ export async function get_free_port(): Promise { export function make_docs_uri(path: string, fragment?: string) { return vscode.Uri.from({ scheme: "gddoc", - path: path + ".gddoc", + path: `${path}.gddoc`, fragment: fragment, }); } diff --git a/src/utils/project_utils.ts b/src/utils/project_utils.ts index edadf23..54b6df6 100644 --- a/src/utils/project_utils.ts +++ b/src/utils/project_utils.ts @@ -9,11 +9,11 @@ let projectFile: string | undefined = undefined; export async function get_project_dir(): Promise { let file = ""; if (vscode.workspace.workspaceFolders !== undefined) { - const files = await vscode.workspace.findFiles("**/project.godot"); + const files = await vscode.workspace.findFiles("**/project.godot", null); if (files.length === 0) { return undefined; - } + } if (files.length === 1) { file = files[0].fsPath; if (!fs.existsSync(file) || !fs.statSync(file).isFile()) { @@ -77,7 +77,7 @@ export function find_project_file(start: string, depth: number = 20) { if (start === ".") { if (fs.existsSync("project.godot") && fs.statSync("project.godot").isFile()) { return "project.godot"; - } + } return null; } const folder = path.dirname(start);