File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( / \. s o l \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 ) ;
You can’t perform that action at this time.
0 commit comments