From 1702def0b3a6a48d56f08049992b76984ff63fac Mon Sep 17 00:00:00 2001 From: 0xtekgrinder <0xtekgrinder@protonmail.com> Date: Wed, 21 Feb 2024 20:23:39 -0500 Subject: [PATCH] fix: ignore files based on the path within the workspace folder --- .../solidity/extension/src/gas-estimation.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/toolchains/solidity/extension/src/gas-estimation.ts b/toolchains/solidity/extension/src/gas-estimation.ts index 5336061a..49fe366d 100644 --- a/toolchains/solidity/extension/src/gas-estimation.ts +++ b/toolchains/solidity/extension/src/gas-estimation.ts @@ -287,7 +287,12 @@ export function registerGasEstimation() { // Generate the report when the file is opened or saved vscode.workspace.onDidOpenTextDocument(async (document) => { // gas estimate only the main contracts - if (document.uri.path.includes("lib") || document.uri.path.includes("test") || document.uri.path.includes("script") || document.uri.path.includes(".git") || !forgeInstalled) { + const workspacePath = vscode.workspace.workspaceFolders?.[0].uri.path; + if (!workspacePath) { + return; + } + const cleanPath = document.uri.path.replace(workspacePath, ""); + if (cleanPath.includes("lib") || cleanPath.includes("test") || cleanPath.includes("script") || cleanPath.includes(".git") || !forgeInstalled) { return; } const report = await gasReport(document.getText(), document.uri.path); @@ -299,7 +304,12 @@ export function registerGasEstimation() { }); vscode.workspace.onDidSaveTextDocument(async (document) => { // gas estimate only the main contracts - if (document.uri.path.includes("lib") || document.uri.path.includes("test") || document.uri.path.includes("script") || document.uri.path.includes(".git") || !forgeInstalled) { + const workspacePath = vscode.workspace.workspaceFolders?.[0].uri.path; + if (!workspacePath) { + return; + } + const cleanPath = document.uri.path.replace(workspacePath, ""); + if (cleanPath.includes("lib") || cleanPath.includes("test") || cleanPath.includes("script") || cleanPath.includes(".git") || !forgeInstalled) { return; } const report = await gasReport(document.getText(), document.uri.path);