@@ -179,41 +179,34 @@ export class HoverController extends Disposable implements IEditorContribution {
179
179
this . _hideWidgets ( ) ;
180
180
}
181
181
182
- private _isMouseOverWidget ( mouseEvent : IEditorMouseEvent ) : boolean {
182
+ private _isMouseOverHoverWidget ( mouseEvent : IEditorMouseEvent ) : boolean {
183
183
184
- const target = mouseEvent . target ;
185
184
const sticky = this . _hoverSettings . sticky ;
186
- if (
187
- sticky
188
- && target . type === MouseTargetType . CONTENT_WIDGET
189
- && target . detail === ContentHoverWidget . ID
190
- ) {
191
- // mouse moved on top of content hover widget
192
- return true ;
185
+
186
+ const isMouseOnMarginHoverWidget = ( mouseEvent : IEditorMouseEvent , sticky : boolean ) => {
187
+ const target = mouseEvent . target ;
188
+ return sticky
189
+ && target . type === MouseTargetType . OVERLAY_WIDGET
190
+ && target . detail === MarginHoverWidget . ID ;
193
191
}
194
- if (
195
- sticky
196
- && this . _contentWidget ?. containsNode ( mouseEvent . event . browserEvent . view ?. document . activeElement )
197
- && ! mouseEvent . event . browserEvent . view ?. getSelection ( ) ?. isCollapsed
198
- ) {
199
- // selected text within content hover widget
200
- return true ;
192
+ const isMouseOnContentHoverWidget = ( mouseEvent : IEditorMouseEvent , sticky : boolean ) => {
193
+ const target = mouseEvent . target ;
194
+ const isMouseOnContentHoverWidget = target . type === MouseTargetType . CONTENT_WIDGET && target . detail === ContentHoverWidget . ID ;
195
+ const isColorPickerVisible = this . _contentWidget ?. isColorPickerVisible ;
196
+ return isMouseOnContentHoverWidget && ( sticky || isColorPickerVisible ) ;
201
197
}
202
- if (
203
- ! sticky
204
- && target . type === MouseTargetType . CONTENT_WIDGET
205
- && target . detail === ContentHoverWidget . ID
206
- && this . _contentWidget ?. isColorPickerVisible
207
- ) {
208
- // though the hover is not sticky, the color picker is sticky
209
- return true ;
198
+ // TODO@aiday -mar verify if the following is necessary code
199
+ const isTextSelectedWithinContentHoverWidget = ( mouseEvent : IEditorMouseEvent , sticky : boolean ) => {
200
+ return sticky
201
+ && this . _contentWidget ?. containsNode ( mouseEvent . event . browserEvent . view ?. document . activeElement )
202
+ && ! mouseEvent . event . browserEvent . view ?. getSelection ( ) ?. isCollapsed
210
203
}
204
+
211
205
if (
212
- sticky
213
- && target . type === MouseTargetType . OVERLAY_WIDGET
214
- && target . detail === MarginHoverWidget . ID
206
+ isMouseOnMarginHoverWidget ( mouseEvent , sticky )
207
+ || isMouseOnContentHoverWidget ( mouseEvent , sticky )
208
+ || isTextSelectedWithinContentHoverWidget ( mouseEvent , sticky )
215
209
) {
216
- // mouse moved on top of overlay hover widget
217
210
return true ;
218
211
}
219
212
return false ;
@@ -232,7 +225,7 @@ export class HoverController extends Disposable implements IEditorContribution {
232
225
return ;
233
226
}
234
227
235
- const mouseIsOverWidget = this . _isMouseOverWidget ( mouseEvent ) ;
228
+ const mouseIsOverWidget = this . _isMouseOverHoverWidget ( mouseEvent ) ;
236
229
// If the mouse is over the widget and the hiding timeout is defined, then cancel it
237
230
if ( mouseIsOverWidget ) {
238
231
this . _reactToEditorMouseMoveRunner . cancel ( ) ;
0 commit comments