@@ -23,6 +23,7 @@ import './hover.css';
23
23
import { Emitter } from '../../../../base/common/event.js' ;
24
24
import { isOnColorDecorator } from '../../colorPicker/browser/hoverColorPicker/hoverColorPicker.js' ;
25
25
import { KeyCode } from '../../../../base/common/keyCodes.js' ;
26
+ import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js' ;
26
27
27
28
// sticky hover widget which doesn't disappear on focus out and such
28
29
const _sticky = false
@@ -54,8 +55,11 @@ export class ContentHoverController extends Disposable implements IEditorContrib
54
55
private _hoverSettings ! : IHoverSettings ;
55
56
private _isMouseDown : boolean = false ;
56
57
58
+ private _ignoreMouseEvents : boolean = false ;
59
+
57
60
constructor (
58
61
private readonly _editor : ICodeEditor ,
62
+ @IContextMenuService _contextMenuService : IContextMenuService ,
59
63
@IInstantiationService private readonly _instantiationService : IInstantiationService ,
60
64
@IKeybindingService private readonly _keybindingService : IKeybindingService
61
65
) {
@@ -67,6 +71,13 @@ export class ContentHoverController extends Disposable implements IEditorContrib
67
71
}
68
72
} , 0
69
73
) ) ;
74
+ this . _register ( _contextMenuService . onDidShowContextMenu ( ( ) => {
75
+ this . hideContentHover ( ) ;
76
+ this . _ignoreMouseEvents = true ;
77
+ } ) ) ;
78
+ this . _register ( _contextMenuService . onDidHideContextMenu ( ( ) => {
79
+ this . _ignoreMouseEvents = false ;
80
+ } ) ) ;
70
81
this . _hookListeners ( ) ;
71
82
this . _register ( this . _editor . onDidChangeConfiguration ( ( e : ConfigurationChangedEvent ) => {
72
83
if ( e . hasChanged ( EditorOption . hover ) ) {
@@ -115,12 +126,18 @@ export class ContentHoverController extends Disposable implements IEditorContrib
115
126
}
116
127
117
128
private _onEditorScrollChanged ( e : IScrollEvent ) : void {
129
+ if ( this . _ignoreMouseEvents ) {
130
+ return ;
131
+ }
118
132
if ( e . scrollTopChanged || e . scrollLeftChanged ) {
119
133
this . hideContentHover ( ) ;
120
134
}
121
135
}
122
136
123
137
private _onEditorMouseDown ( mouseEvent : IEditorMouseEvent ) : void {
138
+ if ( this . _ignoreMouseEvents ) {
139
+ return ;
140
+ }
124
141
this . _isMouseDown = true ;
125
142
const shouldKeepHoverWidgetVisible = this . _shouldKeepHoverWidgetVisible ( mouseEvent ) ;
126
143
if ( shouldKeepHoverWidgetVisible ) {
@@ -141,10 +158,16 @@ export class ContentHoverController extends Disposable implements IEditorContrib
141
158
}
142
159
143
160
private _onEditorMouseUp ( ) : void {
161
+ if ( this . _ignoreMouseEvents ) {
162
+ return ;
163
+ }
144
164
this . _isMouseDown = false ;
145
165
}
146
166
147
167
private _onEditorMouseLeave ( mouseEvent : IPartialEditorMouseEvent ) : void {
168
+ if ( this . _ignoreMouseEvents ) {
169
+ return ;
170
+ }
148
171
if ( this . shouldKeepOpenOnEditorMouseMoveOrLeave ) {
149
172
return ;
150
173
}
@@ -198,6 +221,9 @@ export class ContentHoverController extends Disposable implements IEditorContrib
198
221
}
199
222
200
223
private _onEditorMouseMove ( mouseEvent : IEditorMouseEvent ) : void {
224
+ if ( this . _ignoreMouseEvents ) {
225
+ return ;
226
+ }
201
227
this . _mouseMoveEvent = mouseEvent ;
202
228
const shouldKeepCurrentHover = this . _shouldKeepCurrentHover ( mouseEvent ) ;
203
229
if ( shouldKeepCurrentHover ) {
@@ -236,6 +262,9 @@ export class ContentHoverController extends Disposable implements IEditorContrib
236
262
}
237
263
238
264
private _onKeyDown ( e : IKeyboardEvent ) : void {
265
+ if ( this . _ignoreMouseEvents ) {
266
+ return ;
267
+ }
239
268
if ( ! this . _contentWidget ) {
240
269
return ;
241
270
}
0 commit comments