@@ -654,12 +654,15 @@ class DefaultClient implements Client {
654
654
// Recycle the active text decorations when we receive a new set of inactive regions
655
655
let valuePair : DecorationRangesPair = this . inactiveRegionsDecorations . get ( params . uri ) ;
656
656
if ( valuePair ) {
657
- // Disposing of and resetting the decoration will undo previously applied text decorations
658
- valuePair . decoration . dispose ( ) ;
659
- valuePair . decoration = decoration ;
660
-
661
- // As vscode.TextEditor.setDecorations only applies to visible editors, we must cache the range for when another editor becomes visible
662
- valuePair . ranges = params . ranges ;
657
+ // The language server will send notifications regardless of whether the ranges have changed. Unfortunately we must check for changes ourselves
658
+ if ( this . isRangesEqual ( valuePair . ranges , params . ranges ) ) {
659
+ // Disposing of and resetting the decoration will undo previously applied text decorations
660
+ valuePair . decoration . dispose ( ) ;
661
+ valuePair . decoration = decoration ;
662
+
663
+ // 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 ;
665
+ }
663
666
} else { // The entry does not exist. Make a new one
664
667
let toInsert : DecorationRangesPair = {
665
668
decoration : decoration ,
@@ -675,6 +678,21 @@ class DefaultClient implements Client {
675
678
}
676
679
}
677
680
681
+ // Helper method to compare two ranges for equality
682
+ private isRangesEqual ( r1 : vscode . Range [ ] , r2 : vscode . Range [ ] ) : boolean {
683
+ if ( r1 . length !== r2 . length ) {
684
+ return false ;
685
+ }
686
+
687
+ for ( let e1 of r1 ) {
688
+ for ( let e2 of r2 ) {
689
+ if ( e1 !== e2 ) {
690
+ return false ;
691
+ }
692
+ }
693
+ }
694
+ }
695
+
678
696
/*********************************************
679
697
* requests to the language server
680
698
*********************************************/
0 commit comments