Skip to content

Commit 6d95ed9

Browse files
committed
fix(typescript): focus update target file version on association dirty
1 parent 3f0decd commit 6d95ed9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/language-core/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export const defaultMapperFactory: MapperFactory = mappings => new SourceMap(map
2222
export function createLanguage<T>(
2323
plugins: LanguagePlugin<T>[],
2424
scriptRegistry: Map<T, SourceScript<T>>,
25-
sync: (id: T, includeFsFiles: boolean, shouldRegister: boolean) => void
25+
sync: (id: T, includeFsFiles: boolean, shouldRegister: boolean) => void,
26+
onAssociationDirty?: (targetId: T) => void
2627
) {
2728
const virtualCodeToSourceScriptMap = new WeakMap<VirtualCode, SourceScript<T>>();
2829
const virtualCodeToSourceMap = new WeakMap<IScriptSnapshot, WeakMap<IScriptSnapshot, Mapper>>();
@@ -213,6 +214,7 @@ export function createLanguage<T>(
213214
const sourceScript = scriptRegistry.get(id);
214215
if (sourceScript) {
215216
sourceScript.isAssociationDirty = true;
217+
onAssociationDirty?.(sourceScript.id);
216218
}
217219
});
218220
}

packages/typescript/lib/quickstart/languageServicePluginCommon.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ export function createLanguageCommon(
6060
else {
6161
language.scripts.delete(fileName);
6262
}
63+
},
64+
targetFileName => {
65+
// https://github.com/JetBrains/intellij-plugins/blob/6435723ad88fa296b41144162ebe3b8513f4949b/Angular/src-js/angular-service/src/ngCommands.ts#L88
66+
(info.session as any).change({
67+
file: targetFileName,
68+
line: 1,
69+
offset: 1,
70+
endLine: 1,
71+
endOffset: 1,
72+
insertString: '',
73+
});
6374
}
6475
);
6576

0 commit comments

Comments
 (0)