File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
frontend/src/core/codemirror/lsp Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,14 @@ export class NotebookLanguageServerClient implements ILanguageServerClient {
102102
103103 private static readonly SEEN_CELL_DOCUMENT_URIS = new Set < CellDocumentUri > ( ) ;
104104
105+ /**
106+ * Cache of completion items to avoid jitter while typing in the same completion item
107+ */
108+ private readonly completionItemCache = new LRUCache <
109+ string ,
110+ Promise < LSP . CompletionItem >
111+ > ( 10 ) ;
112+
105113 constructor (
106114 client : ILanguageServerClient ,
107115 initialSettings : Record < string , unknown > ,
@@ -428,10 +436,19 @@ export class NotebookLanguageServerClient implements ILanguageServerClient {
428436 } ;
429437 }
430438
431- completionItemResolve (
439+ async completionItemResolve (
432440 params : LSP . CompletionItem ,
433441 ) : Promise < LSP . CompletionItem > {
434- return this . client . completionItemResolve ( params ) ;
442+ // Used cached result to avoid jitter while typing in the same completion item
443+ const key = JSON . stringify ( params ) ;
444+ const cached = this . completionItemCache . get ( key ) ;
445+ if ( cached ) {
446+ return cached ;
447+ }
448+
449+ const resolved = this . client . completionItemResolve ( params ) ;
450+ this . completionItemCache . set ( key , resolved ) ;
451+ return resolved ;
435452 }
436453
437454 async textDocumentPrepareRename (
You can’t perform that action at this time.
0 commit comments