@@ -31,12 +31,12 @@ export class ContentHoverController extends Disposable {
31
31
32
32
private readonly _participants : IEditorHoverParticipant [ ] ;
33
33
private readonly _widget = this . _register ( this . _instantiationService . createInstance ( ContentHoverWidget , this . _editor ) ) ;
34
- private readonly _decorations = this . _editor . createDecorationsCollection ( ) ;
35
34
private readonly _computer : ContentHoverComputer ;
36
35
private readonly _hoverOperation : HoverOperation < IHoverPart > ;
37
36
38
37
private _messages : IHoverPart [ ] ;
39
38
private _messagesAreComplete : boolean ;
39
+ private _isChangingDecorations : boolean = false ;
40
40
41
41
constructor (
42
42
private readonly _editor : ICodeEditor ,
@@ -61,7 +61,12 @@ export class ContentHoverController extends Disposable {
61
61
this . _register ( this . _hoverOperation . onResult ( ( result ) => {
62
62
this . _withResult ( result . value , result . isComplete , result . hasLoadingMessage ) ;
63
63
} ) ) ;
64
- this . _register ( this . _decorations . onDidChange ( ( ) => this . _onModelDecorationsChanged ( ) ) ) ;
64
+ this . _register ( this . _editor . onDidChangeModelDecorations ( ( ) => {
65
+ if ( this . _isChangingDecorations ) {
66
+ return ;
67
+ }
68
+ this . _onModelDecorationsChanged ( ) ;
69
+ } ) ) ;
65
70
this . _register ( dom . addStandardDisposableListener ( this . _widget . getDomNode ( ) , 'keydown' , ( e ) => {
66
71
if ( e . equals ( KeyCode . Escape ) ) {
67
72
this . hide ( ) ;
@@ -225,12 +230,23 @@ export class ContentHoverController extends Disposable {
225
230
226
231
if ( fragment . hasChildNodes ( ) ) {
227
232
if ( highlightRange ) {
228
- this . _decorations . set ( [ {
229
- range : highlightRange ,
230
- options : ContentHoverController . _DECORATION_OPTIONS
231
- } ] ) ;
233
+ const highlightDecoration = this . _editor . createDecorationsCollection ( ) ;
234
+ try {
235
+ this . _isChangingDecorations = true ;
236
+ highlightDecoration . set ( [ {
237
+ range : highlightRange ,
238
+ options : ContentHoverController . _DECORATION_OPTIONS
239
+ } ] ) ;
240
+ } finally {
241
+ this . _isChangingDecorations = false ;
242
+ }
232
243
disposables . add ( toDisposable ( ( ) => {
233
- this . _decorations . clear ( ) ;
244
+ try {
245
+ this . _isChangingDecorations = true ;
246
+ highlightDecoration . clear ( ) ;
247
+ } finally {
248
+ this . _isChangingDecorations = false ;
249
+ }
234
250
} ) ) ;
235
251
}
236
252
0 commit comments