Skip to content

Commit

Permalink
fix: moving components doesn't trigger import updates
Browse files Browse the repository at this point in the history
close #1884
  • Loading branch information
johnsoncodehk committed Sep 19, 2022
1 parent 3dfd407 commit a13eaf1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/language-service/src/languageFeatures/fileRename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { LanguageServiceRuntimeContext } from '../types';
import { embeddedEditToSourceEdit } from './rename';
import type * as _ from 'vscode-languageserver-protocol';
import * as dedupe from '../utils/dedupe';
import { forEachEmbeddeds } from '@volar/language-core';

export function register(context: LanguageServiceRuntimeContext) {

Expand All @@ -10,8 +11,21 @@ export function register(context: LanguageServiceRuntimeContext) {
const vueDocument = context.documents.get(oldUri);

if (vueDocument) {
oldUri += '.ts';
newUri += '.ts';

let tsExt: string | undefined;

forEachEmbeddeds(vueDocument.file.embeddeds, embedded => {
if (embedded.isTsHostFile && embedded.fileName.replace(vueDocument.file.fileName, '').match(/^\.(js|ts)x?$/)) {
tsExt = embedded.fileName.substring(embedded.fileName.lastIndexOf('.'));
}
});

if (!tsExt) {
return;
}

oldUri += tsExt;
newUri += tsExt;
}

for (const plugin of context.plugins) {
Expand Down

0 comments on commit a13eaf1

Please sign in to comment.