@@ -23,6 +23,7 @@ import Indexer from './indexing/Indexer'
2323import RenameSymbolProvider from './providers/rename/RenameSymbolProvider'
2424import HighlightSymbolProvider from './providers/highlighting/HighlightSymbolProvider'
2525import SemanticTokensProvider , { SEMANTIC_TOKEN_TYPES , SEMANTIC_TOKEN_MODIFIERS } from './providers/semanticTokens/SemanticTokensProvider'
26+ import setupSemanticTokenRefresh from './providers/semanticTokens/setupSemanticTokenRefresh'
2627import { RequestType } from './indexing/SymbolSearchService'
2728import { cacheAndClearProxyEnvironmentVariables } from './utils/ProxyUtils'
2829import MatlabDebugAdaptorServer from './debug/MatlabDebugAdaptorServer'
@@ -375,23 +376,7 @@ export async function startServer (): Promise<void> {
375376 connection . onRequest ( SemanticTokensRequest . method , async ( params : SemanticTokensParams ) => {
376377 return await semanticTokensProvider . handleSemanticTokensRequest ( params , documentManager )
377378 } )
378-
379- // Ensures that semantic tokens are refreshed after indexing,
380- // so highlighting is updated after opening the editor.
381- documentIndexer . setOnIndexed ( ( ) => {
382- scheduleSemanticRefresh ( )
383- } )
384-
385- let refreshTimer : NodeJS . Timeout | undefined
386-
387- function scheduleSemanticRefresh ( ) : void {
388- if ( refreshTimer != null ) clearTimeout ( refreshTimer )
389-
390- // Delay sending the refresh notification to batch multiple indexing updates together
391- refreshTimer = setTimeout ( ( ) => {
392- void connection . sendRequest ( 'workspace/semanticTokens/refresh' )
393- } , 150 )
394- }
379+ setupSemanticTokenRefresh ( connection , documentIndexer )
395380}
396381
397382/** -------------------- Helper Functions -------------------- **/
0 commit comments