@@ -822,24 +822,29 @@ function! s:OnFileReadyToParse( ... )
822822 \ s: pollers .file_parse_response.wait_milliseconds,
823823 \ function ( ' s:PollFileParseResponse' ) )
824824
825- call s: UpdateSemanticHighlighting ( bufnr () )
825+ call s: UpdateSemanticHighlighting ( bufnr (), 1 , 0 )
826826 call s: UpdateInlayHints ( bufnr (), 1 , 0 )
827827
828828 endif
829829endfunction
830830
831- function ! s: UpdateSemanticHighlighting ( bufnr ) abort
831+ function ! s: UpdateSemanticHighlighting ( bufnr , force, redraw_anyway ) abort
832832 call s: StopPoller ( s: pollers .semantic_highlighting )
833833 if ! s: is_neovim &&
834834 \ get ( b: , ' ycm_enable_semantic_highlighting' ,
835835 \ get ( g: , ' ycm_enable_semantic_highlighting' , 0 ) )
836836
837- py3 ycm_state.Buffer (
838- \ int ( vim .eval ( " a:bufnr" ) ) ).SendSemanticTokensRequest ()
839- let s: pollers .semantic_highlighting.id = timer_start (
840- \ s: pollers .semantic_highlighting.wait_milliseconds,
841- \ function ( ' s:PollSemanticHighlighting' , [ a: bufnr ] ) )
842-
837+ if py3eval (
838+ \ ' ycm_state.Buffer( int( vim.eval( "a:bufnr" ) ) ).'
839+ \ . ' semantic_highlighting.Request( '
840+ \ . ' force=int( vim.eval( "a:force" ) ) )' )
841+ let s: pollers .semantic_highlighting.id = timer_start (
842+ \ s: pollers .semantic_highlighting.wait_milliseconds,
843+ \ function ( ' s:PollSemanticHighlighting' , [ a: bufnr ] ) )
844+ elseif a: redraw_anyway
845+ py3 ycm_state.Buffer (
846+ \ int ( vim .eval ( " a:bufnr" ) ) ).semantic_highlighting.Refresh ()
847+ endif
843848 endif
844849endfunction
845850
@@ -850,7 +855,7 @@ function s:ShouldUseInlayHintsNow( bufnr )
850855 \ get ( g: , ' ycm_enable_inlay_hints' , 0 ) )
851856endfunction
852857
853- function ! s: UpdateInlayHints ( bufnr , force, redraw_anyway )
858+ function ! s: UpdateInlayHints ( bufnr , force, redraw_anyway ) abort
854859 call s: StopPoller ( s: pollers .inlay_hints )
855860
856861 if s: ShouldUseInlayHintsNow ( a: bufnr )
@@ -883,36 +888,29 @@ function! s:PollFileParseResponse( ... )
883888endfunction
884889
885890
886- function ! s: PollSemanticHighlighting ( bufnr , ... )
887- if ! py3eval (
888- \ ' ycm_state.Buffer( int( vim.eval( "a:bufnr" ) ) )'
889- \ . ' .SemanticTokensRequestReady()' )
890- let s: pollers .semantic_highlighting.id = timer_start (
891- \ s: pollers .semantic_highlighting.wait_milliseconds,
892- \ function ( ' s:PollSemanticHighlighting' , [ a: bufnr ] ) )
893- elseif ! py3eval (
894- \ ' ycm_state.Buffer( int( vim.eval( "a:bufnr" ) ) )'
895- \ . ' .UpdateSemanticTokens()' )
896- let s: pollers .semantic_highlighting.id = timer_start (
897- \ s: pollers .semantic_highlighting.wait_milliseconds,
898- \ function ( ' s:PollSemanticHighlighting' , [ a: bufnr ] ) )
899- endif
891+ function ! s: PollSemanticHighlighting ( bufnr , ... ) abort
892+ return s: PollScrollable ( a: bufnr , ' semantic_highlighting' )
893+ endfunction
894+
895+
896+ function ! s: PollInlayHints ( bufnr , ... ) abort
897+ return s: PollScrollable ( a: bufnr , ' inlay_hints' )
900898endfunction
901899
902900
903- function ! s: PollInlayHints ( bufnr , ... )
901+ function ! s: PollScrollable ( bufnr , scrollable, ... ) abort
904902 if ! py3eval (
905903 \ ' ycm_state.Buffer( int( vim.eval( "a:bufnr" ) ) )'
906- \ . ' .inlay_hints .Ready()' )
907- let s: pollers.inlay_hints .id = timer_start (
908- \ s: pollers.inlay_hints .wait_milliseconds,
909- \ function ( ' s:PollInlayHints ' , [ a: bufnr ] ) )
904+ \ . ' .' . a: scrollable . ' .Ready()' )
905+ let s: pollers[ a: scrollable ] .id = timer_start (
906+ \ s: pollers[ a: scrollable ] .wait_milliseconds,
907+ \ function ( ' s:PollScrollable ' , [ a: bufnr, a: scrollable ] ) )
910908 elseif ! py3eval (
911909 \ ' ycm_state.Buffer( int( vim.eval( "a:bufnr" ) ) )'
912- \ . ' .inlay_hints .Update()' )
913- let s: pollers.inlay_hints .id = timer_start (
914- \ s: pollers.inlay_hints .wait_milliseconds,
915- \ function ( ' s:PollInlayHints ' , [ a: bufnr ] ) )
910+ \ . ' .' . a: scrollable . ' .Update()' )
911+ let s: pollers[ a: scrollable ] .id = timer_start (
912+ \ s: pollers[ a: scrollable ] .wait_milliseconds,
913+ \ function ( ' s:PollScrollable ' , [ a: bufnr, a: scrollable ] ) )
916914 endif
917915endfunction
918916
@@ -973,7 +971,7 @@ function! s:OnWinScrolled()
973971 return
974972 endif
975973 let bufnr = winbufnr ( expand ( ' <afile>' ) )
976- call s: UpdateSemanticHighlighting ( bufnr )
974+ call s: UpdateSemanticHighlighting ( bufnr , 0 , 0 )
977975 call s: UpdateInlayHints ( bufnr , 0 , 0 )
978976endfunction
979977
0 commit comments