Skip to content

Commit 0a10d91

Browse files
committed
chore: remove decorations for test and scripts
1 parent 5c7748d commit 0a10d91

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/commands/contract-size.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,29 @@ function activate(context) {
2323

2424
context.subscriptions.push(
2525
vscode.workspace.onDidChangeTextDocument(event => {
26-
if (event.document.languageId === 'solidity') {
26+
if (event.document.languageId === 'solidity' && isNotScriptOrTest(event.document.fileName)) {
2727
updateDecorations(event.document);
2828
}
2929
}),
3030
vscode.window.onDidChangeActiveTextEditor(editor => {
31-
if (editor?.document.languageId === 'solidity') {
31+
if (editor?.document.languageId === 'solidity' && isNotScriptOrTest(editor.document.fileName)) {
3232
updateDecorations(editor.document);
3333
}
3434
})
3535
);
3636

37-
if (vscode.window.activeTextEditor?.document.languageId === 'solidity') {
37+
if (vscode.window.activeTextEditor?.document.languageId === 'solidity' &&
38+
isNotScriptOrTest(vscode.window.activeTextEditor.document.fileName)) {
3839
updateDecorations(vscode.window.activeTextEditor.document);
3940
}
4041

4142
console.info('contract-size: Activation complete');
4243
}
4344

45+
function isNotScriptOrTest(fileName) {
46+
return fileName.endsWith('.sol') && !fileName.endsWith('.t.sol') && !fileName.endsWith('.s.sol');
47+
}
48+
4449
function loadConfig() {
4550
const foundryConfigPath = path.join(workspaceRoot, 'foundry.toml');
4651

@@ -84,11 +89,12 @@ function updateDecorations(document) {
8489
const config = vscode.workspace.getConfiguration('solidityInspector');
8590
const showContractSize = config.get('showContractSize');
8691

87-
if (!showContractSize) {
88-
// Clear decorations if the feature is disabled
92+
if (!showContractSize || !isNotScriptOrTest(document.fileName)) {
93+
// Clear decorations if the feature is disabled or it's not a regular .sol file
8994
vscode.window.activeTextEditor?.setDecorations(decorationType, []);
9095
return;
9196
}
97+
9298
const text = document.getText();
9399
const contractSizes = getContractSizes(document.fileName);
94100
const decorations = [];

0 commit comments

Comments
 (0)