@@ -331,19 +331,26 @@ impl State {
331
331
} )
332
332
} ) . collect :: < Result < Vec < _ > > > ( ) ?;
333
333
334
- let source = if let Some ( source) = self . document_highlight_source {
335
- source
336
- } else {
337
- let source = self . call (
338
- None ,
339
- "nvim_buf_add_highlight" ,
340
- json ! ( [ 0 , 0 , "Error" , 1 , 1 , 1 ] ) ,
341
- ) ?;
342
- self . document_highlight_source = Some ( source) ;
343
- source
344
- } ;
334
+ let HighlightSource { buffer, source } =
335
+ if let Some ( highlight_source) = self . document_highlight_source {
336
+ highlight_source
337
+ } else {
338
+ let buffer = self . call ( None , "nvim_win_get_buf" , json ! ( [ 0 ] ) ) ?;
339
+ let source = self . call (
340
+ None ,
341
+ "nvim_buf_add_highlight" ,
342
+ json ! ( [ buffer, 0 , "Error" , 1 , 1 , 1 ] ) ,
343
+ ) ?;
344
+ let highlight_source = HighlightSource { buffer, source } ;
345
+ self . document_highlight_source = Some ( highlight_source) ;
346
+ highlight_source
347
+ } ;
345
348
346
- self . notify ( None , "nvim_buf_clear_highlight" , json ! ( [ 0 , source, 0 , -1 ] ) ) ?;
349
+ self . notify (
350
+ None ,
351
+ "nvim_buf_clear_highlight" ,
352
+ json ! ( [ buffer, source, 0 , -1 ] ) ,
353
+ ) ?;
347
354
self . notify ( None , "s:AddHighlights" , json ! ( [ source, highlights] ) ) ?;
348
355
}
349
356
@@ -354,8 +361,12 @@ impl State {
354
361
pub fn languageClient_clearDocumentHighlight ( & mut self , _: & Value ) -> Result < ( ) > {
355
362
info ! ( "Begin {}" , NOTIFICATION__ClearDocumentHighlight ) ;
356
363
357
- if let Some ( source) = self . document_highlight_source . take ( ) {
358
- self . notify ( None , "nvim_buf_clear_highlight" , json ! ( [ 0 , source, 0 , -1 ] ) ) ?;
364
+ if let Some ( HighlightSource { buffer, source } ) = self . document_highlight_source . take ( ) {
365
+ self . notify (
366
+ None ,
367
+ "nvim_buf_clear_highlight" ,
368
+ json ! ( [ buffer, source, 0 , -1 ] ) ,
369
+ ) ?;
359
370
}
360
371
361
372
info ! ( "End {}" , NOTIFICATION__ClearDocumentHighlight ) ;
0 commit comments