From 2b333bb563b717b118e632ee03590032ff025cd2 Mon Sep 17 00:00:00 2001 From: Ta Quang Trung Date: Tue, 11 Jul 2023 00:25:09 +0800 Subject: [PATCH 1/3] vscode-stylua: search configuration file for Lua files not in workspace --- stylua-vscode/src/extension.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stylua-vscode/src/extension.ts b/stylua-vscode/src/extension.ts index b749cc81..d91ea0ac 100644 --- a/stylua-vscode/src/extension.ts +++ b/stylua-vscode/src/extension.ts @@ -1,4 +1,5 @@ import * as vscode from "vscode"; +import * as path from "path"; import { formatCode, checkIgnored } from "./stylua"; import { GitHub } from "./github"; import { StyluaDownloader } from "./download"; @@ -84,7 +85,8 @@ export async function activate(context: vscode.ExtensionContext) { const currentWorkspace = vscode.workspace.getWorkspaceFolder( document.uri ); - const cwd = currentWorkspace?.uri?.fsPath; + // const cwd = currentWorkspace?.uri?.fsPath; + const cwd = path.dirname(document.uri.fsPath); if (await checkIgnored(document.uri, currentWorkspace?.uri)) { return []; From 5fa46f535f33d7f5491e115bcea64d5226eafd1a Mon Sep 17 00:00:00 2001 From: Ta Quang Trung Date: Wed, 9 Aug 2023 18:16:21 +0800 Subject: [PATCH 2/3] vscode-stylua: configure cwd to workspace or parent dir --- stylua-vscode/src/extension.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stylua-vscode/src/extension.ts b/stylua-vscode/src/extension.ts index d91ea0ac..668b7a7d 100644 --- a/stylua-vscode/src/extension.ts +++ b/stylua-vscode/src/extension.ts @@ -86,7 +86,14 @@ export async function activate(context: vscode.ExtensionContext) { document.uri ); // const cwd = currentWorkspace?.uri?.fsPath; - const cwd = path.dirname(document.uri.fsPath); + + const workspacePath = currentWorkspace?.uri?.fsPath; + const documentPath = document.uri.fsPath; + + const cwd = + workspacePath && documentPath.startsWith(workspacePath) + ? workspacePath + : path.dirname(documentPath); if (await checkIgnored(document.uri, currentWorkspace?.uri)) { return []; From d936951f35acf59f2a3ae4e77261ef6fce02b65d Mon Sep 17 00:00:00 2001 From: Ta Quang Trung Date: Wed, 9 Aug 2023 18:18:50 +0800 Subject: [PATCH 3/3] clean code --- stylua-vscode/src/extension.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/stylua-vscode/src/extension.ts b/stylua-vscode/src/extension.ts index 668b7a7d..d4e54078 100644 --- a/stylua-vscode/src/extension.ts +++ b/stylua-vscode/src/extension.ts @@ -85,7 +85,6 @@ export async function activate(context: vscode.ExtensionContext) { const currentWorkspace = vscode.workspace.getWorkspaceFolder( document.uri ); - // const cwd = currentWorkspace?.uri?.fsPath; const workspacePath = currentWorkspace?.uri?.fsPath; const documentPath = document.uri.fsPath;