@@ -24,13 +24,15 @@ connection.onInitialize(params => {
24
24
25
25
const { typescript : ts } = loadTsdkByPath ( options . typescript . tsdk , params . locale ) ;
26
26
const tsconfigProjects = createUriMap < LanguageService > ( ) ;
27
+ const file2ProjectInfo = new Map < string , Promise < ts . server . protocol . ProjectInfo | null > > ( ) ;
27
28
28
29
server . fileWatcher . onDidChangeWatchedFiles ( ( { changes } ) => {
29
30
for ( const change of changes ) {
30
31
const changeUri = URI . parse ( change . uri ) ;
31
32
if ( tsconfigProjects . has ( changeUri ) ) {
32
33
tsconfigProjects . get ( changeUri ) ! . dispose ( ) ;
33
34
tsconfigProjects . delete ( changeUri ) ;
35
+ file2ProjectInfo . clear ( ) ;
34
36
}
35
37
}
36
38
} ) ;
@@ -44,13 +46,18 @@ connection.onInitialize(params => {
44
46
async getLanguageService ( uri ) {
45
47
if ( uri . scheme === 'file' && options . typescript . tsserverRequestCommand ) {
46
48
const fileName = uri . fsPath . replace ( / \\ / g, '/' ) ;
47
- const projectInfo = await sendTsRequest < ts . server . protocol . ProjectInfo > (
48
- ts . server . protocol . CommandTypes . ProjectInfo ,
49
- {
50
- file : fileName ,
51
- needFileNameList : false ,
52
- } satisfies ts . server . protocol . ProjectInfoRequestArgs
53
- ) ;
49
+ let projectInfoPromise = file2ProjectInfo . get ( fileName ) ;
50
+ if ( ! projectInfoPromise ) {
51
+ projectInfoPromise = sendTsRequest < ts . server . protocol . ProjectInfo > (
52
+ ts . server . protocol . CommandTypes . ProjectInfo ,
53
+ {
54
+ file : fileName ,
55
+ needFileNameList : false ,
56
+ }
57
+ ) ;
58
+ file2ProjectInfo . set ( fileName , projectInfoPromise ) ;
59
+ }
60
+ const projectInfo = await projectInfoPromise ;
54
61
if ( projectInfo ) {
55
62
const { configFileName } = projectInfo ;
56
63
let ls = tsconfigProjects . get ( URI . file ( configFileName ) ) ;
0 commit comments