@@ -71,7 +71,12 @@ interface OutputNotificationBody {
71
71
72
72
interface InactiveRegionParams {
73
73
uri : string ;
74
- ranges : vscode . Range [ ] ;
74
+ ranges : InputRange [ ] ;
75
+ }
76
+
77
+ interface InputRange {
78
+ start : { line : number ; character : number } ;
79
+ end : { line : number ; character : number } ;
75
80
}
76
81
77
82
interface DecorationRangesPair {
@@ -651,30 +656,36 @@ class DefaultClient implements Client {
651
656
} ;
652
657
let decoration : vscode . TextEditorDecorationType = vscode . window . createTextEditorDecorationType ( renderOptions ) ;
653
658
659
+ // As InactiveRegionParams.ranges is deserialized as POD, we must convert to vscode.Ranges in order to make use of the API's
660
+ let ranges : vscode . Range [ ] = [ ] ;
661
+ params . ranges . forEach ( element => {
662
+ ranges . push ( new vscode . Range ( element . start . line , element . start . character , element . end . line , element . end . character ) ) ;
663
+ } ) ;
664
+
654
665
// Recycle the active text decorations when we receive a new set of inactive regions
655
666
let valuePair : DecorationRangesPair = this . inactiveRegionsDecorations . get ( params . uri ) ;
656
667
if ( valuePair ) {
657
- // The language server will send notifications regardless of whether the ranges have changed
658
- if ( ! this . areRangesEqual ( valuePair . ranges , params . ranges ) ) {
668
+ // The language server will send notifications regardless of whether the ranges have changed, so we must check to see if the new data reflects a change
669
+ if ( ! this . areRangesEqual ( valuePair . ranges , ranges ) ) {
659
670
// Disposing of and resetting the decoration will undo previously applied text decorations
660
671
valuePair . decoration . dispose ( ) ;
661
672
valuePair . decoration = decoration ;
662
673
663
674
// As vscode.TextEditor.setDecorations only applies to visible editors, we must cache the range for when another editor becomes visible
664
- valuePair . ranges = params . ranges ;
675
+ valuePair . ranges = ranges ;
665
676
}
666
677
} else { // The entry does not exist. Make a new one
667
678
let toInsert : DecorationRangesPair = {
668
679
decoration : decoration ,
669
- ranges : params . ranges
680
+ ranges : ranges
670
681
} ;
671
682
this . inactiveRegionsDecorations . set ( params . uri , toInsert ) ;
672
683
}
673
684
674
685
// Apply the decorations to all *visible* text editors
675
686
let editors : vscode . TextEditor [ ] = vscode . window . visibleTextEditors . filter ( e => e . document . uri . toString ( ) === params . uri ) ;
676
687
for ( let e of editors ) {
677
- e . setDecorations ( decoration , params . ranges ) ;
688
+ e . setDecorations ( decoration , ranges ) ;
678
689
}
679
690
}
680
691
0 commit comments