Skip to content

Commit ddba208

Browse files
committed
🔨 fix: update regex
1 parent 57de7d6 commit ddba208

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/commands/highlight-unused-imports.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ async function unusedImportsActiveFile(editor) {
4242
for (const importStatement of imports) {
4343
const imports = extractImports(importStatement);
4444
for (const item of imports) {
45-
const filePath = item;
4645
const regex = new RegExp(item, 'g');
4746
const itemOccurancesInImportStatement = (importStatement.replace(/\.sol\b/g, '').match(regex) || []).length;
48-
const totalOccurrencesOfItem = (text.match(new RegExp(filePath, 'g')) || []).length;
47+
const totalOccurrencesOfItem = (text.match(new RegExp(`\\b${item}\\b`, 'gi')) || []).length;
4948
if (totalOccurrencesOfItem == itemOccurancesInImportStatement) {
5049
const lineIndex = editor.document.getText().split('\n').findIndex(line => line.includes(importStatement));
5150
const range = new vscode.Range(editor.document.lineAt(lineIndex).range.start, editor.document.lineAt(lineIndex).range.end);

0 commit comments

Comments
 (0)