@@ -46,7 +46,7 @@ export class ModesHoverController implements IEditorContribution {
46
46
private _hoverClicked : boolean ;
47
47
private _isHoverEnabled ! : boolean ;
48
48
private _isHoverSticky ! : boolean ;
49
- private _activatedByColorDecoratorClick : boolean = false ;
49
+ private _hoverActivatedByColorDecoratorClick : boolean = false ;
50
50
51
51
static get ( editor : ICodeEditor ) : ModesHoverController | null {
52
52
return editor . getContribution < ModesHoverController > ( ModesHoverController . ID ) ;
@@ -176,45 +176,17 @@ export class ModesHoverController implements IEditorContribution {
176
176
return ;
177
177
}
178
178
179
- const onDecorator = target . element ?. classList . contains ( 'colorpicker-color-decoration' ) ;
179
+ const mouseOnDecorator = target . element ?. classList . contains ( 'colorpicker-color-decoration' ) ;
180
180
const decoratorActivatedOn = this . _editor . getOption ( EditorOption . colorDecoratorsActivatedOn ) ;
181
181
182
- console . log ( 'onDecorator : ' , onDecorator ) ;
183
- console . log ( 'decoratorActivatedOn : ' , decoratorActivatedOn ) ;
184
-
185
- // TODO: finish the following code whith the option 'click and hover''
186
- // TODO: find out why the color hover seems to disappear when clicking on th box
187
- if ( onDecorator ) {
188
- if ( decoratorActivatedOn === 'click' ) {
189
- if ( ! this . _activatedByColorDecoratorClick ) {
190
- this . _hideWidgets ( ) ;
191
- return ;
192
- }
193
- } else if ( decoratorActivatedOn === 'hover' ) {
194
- if ( this . _activatedByColorDecoratorClick ) {
195
- throw new Error ( 'Invalid state' ) ;
196
- } else {
197
- if ( ! this . _isHoverEnabled ) {
198
- this . _hideWidgets ( ) ;
199
- return ;
200
- }
201
- }
202
- } else if ( decoratorActivatedOn === 'click and hover' ) {
203
- console . log ( 'entered into the third case' ) ;
204
- if ( ! this . _activatedByColorDecoratorClick ) {
205
- if ( ! this . _isHoverEnabled ) {
206
- this . _hideWidgets ( ) ;
207
- return ;
208
- }
209
- }
210
- } else {
211
- throw new Error ( 'Invalid value for EditorOption.colorDecoratorsActivatedOn' ) ;
212
- }
213
- } else {
214
- if ( ! this . _isHoverEnabled && ! this . _activatedByColorDecoratorClick ) {
215
- this . _hideWidgets ( ) ;
216
- return ;
217
- }
182
+ if ( ( mouseOnDecorator && (
183
+ ( decoratorActivatedOn === 'click' && ! this . _hoverActivatedByColorDecoratorClick ) ||
184
+ ( decoratorActivatedOn === 'hover' && ! this . _isHoverEnabled ) ||
185
+ ( decoratorActivatedOn === 'click and hover' && ! this . _isHoverEnabled && ! this . _hoverActivatedByColorDecoratorClick ) ) )
186
+ || ! mouseOnDecorator && ! this . _isHoverEnabled && ! this . _hoverActivatedByColorDecoratorClick
187
+ ) {
188
+ this . _hideWidgets ( ) ;
189
+ return ;
218
190
}
219
191
220
192
const contentWidget = this . _getOrCreateContentWidget ( ) ;
@@ -256,7 +228,7 @@ export class ModesHoverController implements IEditorContribution {
256
228
if ( ( this . _isMouseDown && this . _hoverClicked && this . _contentWidget ?. isColorPickerVisible ( ) ) || InlineSuggestionHintsContentWidget . dropDownVisible ) {
257
229
return ;
258
230
}
259
- this . _activatedByColorDecoratorClick = false ;
231
+ this . _hoverActivatedByColorDecoratorClick = false ;
260
232
this . _hoverClicked = false ;
261
233
this . _glyphWidget ?. hide ( ) ;
262
234
this . _contentWidget ?. hide ( ) ;
@@ -274,7 +246,7 @@ export class ModesHoverController implements IEditorContribution {
274
246
}
275
247
276
248
public showContentHover ( range : Range , mode : HoverStartMode , source : HoverStartSource , focus : boolean , activatedByColorDecoratorClick : boolean = false ) : void {
277
- this . _activatedByColorDecoratorClick = activatedByColorDecoratorClick ;
249
+ this . _hoverActivatedByColorDecoratorClick = activatedByColorDecoratorClick ;
278
250
this . _getOrCreateContentWidget ( ) . startShowingAtRange ( range , mode , source , focus ) ;
279
251
}
280
252
0 commit comments