@@ -36,7 +36,7 @@ const provideRenameEdits = async ({
3636 ) ;
3737 const matches = await getAllImportModulePaths ( doc ) ;
3838
39- matches . forEach ( async ( match ) => {
39+ for ( const match of matches ) {
4040 const varName = match [ 1 ] ;
4141 const resolvedPath = resolveImportPathWithAliases ( doc , match [ 2 ] ) ;
4242
@@ -53,7 +53,7 @@ const provideRenameEdits = async ({
5353 classNamePositions . forEach ( ( classNamePosition ) => {
5454 edit . replace ( doc . uri , classNamePosition . range , newName ) ;
5555 } ) ;
56- } ) ;
56+ }
5757 }
5858
5959 // Update the Css Module File
@@ -80,13 +80,6 @@ export class ScriptsRenameProvider implements vscode.RenameProvider {
8080 position : vscode . Position ,
8181 newName : string
8282 ) => {
83- if (
84- ( await isPositionInString ( document , position ) ) ||
85- ( await isPositionInComment ( document , position ) )
86- ) {
87- return ;
88- }
89-
9083 const wordRange = document . getWordRangeAtPosition ( position , / \w + / ) ;
9184 if ( ! wordRange ) {
9285 return ;
@@ -106,6 +99,13 @@ export class ScriptsRenameProvider implements vscode.RenameProvider {
10699 return ;
107100 }
108101
102+ if (
103+ ( await isPositionInString ( document , position ) ) ||
104+ ( await isPositionInComment ( document , position ) )
105+ ) {
106+ return ;
107+ }
108+
109109 const cssDoc = await vscode . workspace . openTextDocument ( cssFilePath ) ;
110110
111111 return await provideRenameEdits ( {
@@ -119,13 +119,6 @@ export class ScriptsRenameProvider implements vscode.RenameProvider {
119119 document : vscode . TextDocument ,
120120 position : vscode . Position
121121 ) => {
122- if (
123- ( await isPositionInString ( document , position ) ) ||
124- ( await isPositionInComment ( document , position ) )
125- ) {
126- return ;
127- }
128-
129122 const wordRange = document . getWordRangeAtPosition ( position , / \w + / ) ;
130123 if ( ! wordRange ) {
131124 return ;
@@ -137,6 +130,13 @@ export class ScriptsRenameProvider implements vscode.RenameProvider {
137130 return ;
138131 }
139132
133+ if (
134+ ( await isPositionInString ( document , position ) ) ||
135+ ( await isPositionInComment ( document , position ) )
136+ ) {
137+ return ;
138+ }
139+
140140 return ( await ClassNameCache . hasClassNameFromImportPath (
141141 className ,
142142 getWorkspaceRelativeImportPath ( document , importModulePath )
@@ -152,14 +152,6 @@ export class ModulesRenameProvider implements vscode.RenameProvider {
152152 position : vscode . Position ,
153153 newName : string
154154 ) => {
155- if (
156- ( await isPositionInString ( document , position ) ) ||
157- ( await isPositionInComment ( document , position ) ) ||
158- ! isDocumentModule ( document )
159- ) {
160- return ;
161- }
162-
163155 const wordRange = document . getWordRangeAtPosition (
164156 position ,
165157 / \. [ a - z A - Z 0 - 9 _ - ] + /
@@ -168,6 +160,14 @@ export class ModulesRenameProvider implements vscode.RenameProvider {
168160 return ;
169161 }
170162
163+ if (
164+ ( await isPositionInString ( document , position ) ) ||
165+ ( await isPositionInComment ( document , position ) ) ||
166+ ! isDocumentModule ( document )
167+ ) {
168+ return ;
169+ }
170+
171171 const oldClassName = document . getText ( wordRange ) . replace ( / ^ \. / , "" ) ;
172172
173173 return await provideRenameEdits ( { document, oldClassName, newName } ) ;
0 commit comments