diff --git a/src/features/vsProvider.ts b/src/features/vsProvider.ts index 128452c..5f8e325 100644 --- a/src/features/vsProvider.ts +++ b/src/features/vsProvider.ts @@ -62,8 +62,8 @@ export default class ValeServerProvider implements vscode.CodeActionProvider { private async runVale(file: vscode.TextDocument) { const folder = path.dirname(file.fileName); - const binaryLocation = utils.readBinaryLocation(file); - const configLocation = utils.readFileLocation(file); + const binaryLocation = utils.readBinaryLocation(this.logger, file); + const configLocation = utils.readFileLocation(this.logger, file); if (binaryLocation == null || configLocation == null) { // `file` is not part of the workspace, so we could not resolve a workspace-relative path. Ignore this file. return; diff --git a/src/features/vsUtils.ts b/src/features/vsUtils.ts index 26fa71d..c139ad1 100644 --- a/src/features/vsUtils.ts +++ b/src/features/vsUtils.ts @@ -8,7 +8,7 @@ import * as vscode from "vscode"; // If `customPath` contains `${workspaceFolder}`, replaces it with the workspace that `file` comes from. // Return `null` if `customPath` contains `${workspaceFolder}` and `file` is _not_ part of the workspace. -function replaceWorkspaceFolder(customPath: string, file: vscode.TextDocument): string | null { +function replaceWorkspaceFolder(logger: vscode.OutputChannel, customPath: string, file: vscode.TextDocument): string | null { customPath = path.normalize(customPath); const workspaceFolder = vscode.workspace.getWorkspaceFolder(file.uri); if (workspaceFolder) { @@ -17,25 +17,26 @@ function replaceWorkspaceFolder(customPath: string, file: vscode.TextDocument): workspaceFolder.uri.fsPath ); } + logger.appendLine(`Not running Vale on file '${file.uri}' as it is not contained within the workspace`); return null; } -export const readBinaryLocation = (file: vscode.TextDocument): string | null => { +export const readBinaryLocation = (logger: vscode.OutputChannel, file: vscode.TextDocument): string | null => { const configuration = vscode.workspace.getConfiguration(); let customBinaryPath = configuration.get("vale.valeCLI.path"); if (customBinaryPath) { - return replaceWorkspaceFolder(customBinaryPath, file); + return replaceWorkspaceFolder(logger, customBinaryPath, file); } return which.sync("vale"); }; -export const readFileLocation = (file: vscode.TextDocument): string | null => { +export const readFileLocation = (logger: vscode.OutputChannel, file: vscode.TextDocument): string | null => { const configuration = vscode.workspace.getConfiguration(); let customConfigPath = configuration.get("vale.valeCLI.config"); if (customConfigPath) { - return replaceWorkspaceFolder(customConfigPath, file); + return replaceWorkspaceFolder(logger, customConfigPath, file); } return ""; };