@@ -3,7 +3,7 @@ import { CancellationTokenSource, Disposable, DocumentHighlight, DocumentHighlig
33import events from '../events'
44import languages from '../languages'
55import Document from '../model/document'
6- import { HandlerDelegate , CurrentState } from '../types'
6+ import { HandlerDelegate } from '../types'
77import { disposeAll } from '../util'
88import workspace from '../workspace'
99const logger = require ( '../util/logger' ) ( 'documentHighlight' )
@@ -35,17 +35,11 @@ export default class Highlights {
3535 public async highlight ( ) : Promise < void > {
3636 let { nvim } = this
3737 this . cancel ( )
38- let state : CurrentState
39- try {
40- state = await this . handler . getCurrentState ( )
41- this . handler . checkProvier ( 'documentHighlight' , state . doc . textDocument )
42- } catch ( e ) {
43- return
44- }
45- let { doc, winid, position } = state
46- let cursors = await nvim . eval ( `get(b:,'coc_cursors_activated',0)` ) as number
47- if ( cursors ) return
48- let highlights = await this . getHighlights ( doc , position )
38+ let [ bufnr , winid , pos , cursors ] = await nvim . eval ( `[bufnr("%"),win_getid(),coc#util#cursor(),get(b:,'coc_cursors_activated',0)]` ) as [ number , number , [ number , number ] , number ]
39+ let doc = workspace . getDocument ( bufnr )
40+ if ( ! doc || ! doc . attached || cursors ) return
41+ if ( ! languages . hasProvider ( 'documentHighlight' , doc . textDocument ) ) return
42+ let highlights = await this . getHighlights ( doc , Position . create ( pos [ 0 ] , pos [ 1 ] ) )
4943 if ( ! highlights ) return
5044 let groups : { [ index : string ] : Range [ ] } = { }
5145 for ( let hl of highlights ) {
0 commit comments