File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
packages/jupyterlab-lsp/src/features Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ export class HighlightsFeature extends Feature {
7070 > ;
7171 private _virtualPosition : IVirtualPosition ;
7272 private _versionSent : number ;
73- private _lastToken : CodeEditor . IToken | null = null ;
73+ private _lastToken : {
74+ token : CodeEditor . IToken ;
75+ adapter : WidgetLSPAdapter < any > ;
76+ } | null = null ;
7477
7578 constructor ( options : HighlightsFeature . IOptions ) {
7679 super ( options ) ;
@@ -297,10 +300,12 @@ export class HighlightsFeature extends Feature {
297300 const token = editor . getTokenAt ( offset ) ;
298301
299302 // if token has not changed, no need to update highlight, unless it is an empty token
300- // which would indicate that the cursor is at the first character
303+ // which would indicate that the cursor is at the first character; we also need to check
304+ // adapter in case if user switched between documents/notebooks.
301305 if (
302306 this . _lastToken &&
303- token . value === this . _lastToken . value &&
307+ token . value === this . _lastToken . token . value &&
308+ adapter === this . _lastToken . adapter &&
304309 token . value !== ''
305310 ) {
306311 this . console . log (
@@ -352,7 +357,10 @@ export class HighlightsFeature extends Feature {
352357 }
353358
354359 this . handleHighlight ( highlights , adapter , document ) ;
355- this . _lastToken = token ;
360+ this . _lastToken = {
361+ token,
362+ adapter
363+ } ;
356364 } catch ( e ) {
357365 this . console . warn ( 'Could not get highlights:' , e ) ;
358366 }
You can’t perform that action at this time.
0 commit comments