Skip to content

Commit 00264d9

Browse files
authored
(fix) run update imports when folder renamed/moved
1 parent 4862c8d commit 00264d9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/svelte-vscode/src/extension.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,14 @@ export function activate(context: ExtensionContext) {
226226
function addRenameFileListener(getLS: () => LanguageClient) {
227227
workspace.onDidRenameFiles(async (evt) => {
228228
const oldUri = evt.files[0].oldUri.toString(true);
229-
if (!['.ts', '.js', '.json', '.svelte'].some((ending) => oldUri.endsWith(ending))) {
229+
const parts = oldUri.split(/\/|\\/);
230+
const lastPart = parts[parts.length - 1];
231+
// If user moves/renames a folder, the URI only contains the parts up to that folder,
232+
// and not files. So in case the URI does not contain a '.', check for imports to update.
233+
if (
234+
lastPart.includes('.') &&
235+
!['.ts', '.js', '.json', '.svelte'].some((ending) => lastPart.endsWith(ending))
236+
) {
230237
return;
231238
}
232239

0 commit comments

Comments
 (0)