Skip to content

Commit fb15f1d

Browse files
committed
Cleaning the code, using getters instead
1 parent d656306 commit fb15f1d

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

src/vs/editor/contrib/colorPicker/browser/colorContributions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class ColorContribution extends Disposable implements IEditorContribution
6060
if (!hoverController) {
6161
return;
6262
}
63-
if (!hoverController.isColorPickerVisible()) {
63+
if (!hoverController.isColorPickerVisible) {
6464
const range = new Range(target.range.startLineNumber, target.range.startColumn + 1, target.range.endLineNumber, target.range.endColumn + 1);
6565
hoverController.showContentHover(range, HoverStartMode.Immediate, HoverStartSource.Mouse, false, true);
6666
}

src/vs/editor/contrib/hover/browser/contentHover.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,26 @@ export class ContentHoverController extends Disposable {
215215
this._setCurrentResult(null);
216216
}
217217

218-
public isColorPickerVisible(): boolean {
218+
get isColorPickerVisible(): boolean {
219219
return this._widget.isColorPickerVisible;
220220
}
221221

222-
public isVisibleFromKeyboard(): boolean {
222+
get isVisibleFromKeyboard(): boolean {
223223
return this._widget.isVisibleFromKeyboard;
224224
}
225225

226-
public isVisible(): boolean {
226+
get isVisible(): boolean {
227227
return this._widget.isVisible;
228228
}
229229

230-
public isFocused(): boolean {
230+
get isFocused(): boolean {
231231
return this._widget.isFocused;
232232
}
233233

234+
get isResizing(): boolean {
235+
return this._widget.isResizing;
236+
}
237+
234238
public containsNode(node: Node | null | undefined): boolean {
235239
return (node ? this._widget.getDomNode().contains(node) : false);
236240
}

src/vs/editor/contrib/hover/browser/hover.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class ModesHoverController implements IEditorContribution {
155155
private _onEditorMouseMove(mouseEvent: IEditorMouseEvent): void {
156156
const target = mouseEvent.target;
157157

158-
if (this._contentWidget?.isFocused() || this._contentWidget?.widget.isResizing) {
158+
if (this._contentWidget?.isFocused || this._contentWidget?.isResizing) {
159159
return;
160160
}
161161

@@ -175,7 +175,7 @@ export class ModesHoverController implements IEditorContribution {
175175

176176
if (
177177
!this._isHoverSticky && target.type === MouseTargetType.CONTENT_WIDGET && target.detail === ContentHoverWidget.ID
178-
&& this._contentWidget?.isColorPickerVisible()
178+
&& this._contentWidget?.isColorPickerVisible
179179
) {
180180
// though the hover is not sticky, the color picker needs to.
181181
return;
@@ -186,7 +186,7 @@ export class ModesHoverController implements IEditorContribution {
186186
return;
187187
}
188188

189-
if (this._isHoverSticky && this._contentWidget?.isVisibleFromKeyboard()) {
189+
if (this._isHoverSticky && this._contentWidget?.isVisibleFromKeyboard) {
190190
// Sticky mode is on and the hover has been shown via keyboard
191191
// so moving the mouse has no effect
192192
return;
@@ -233,7 +233,7 @@ export class ModesHoverController implements IEditorContribution {
233233

234234
const resolvedKeyboardEvent = this._keybindingService.softDispatch(e, this._editor.getDomNode());
235235
// If the beginning of a multi-chord keybinding is pressed, or the command aims to focus the hover, set the variable to true, otherwise false
236-
const mightTriggerFocus = (resolvedKeyboardEvent.kind === ResultKind.MoreChordsNeeded || (resolvedKeyboardEvent.kind === ResultKind.KbFound && resolvedKeyboardEvent.commandId === 'editor.action.showHover' && this._contentWidget?.isVisible()));
236+
const mightTriggerFocus = (resolvedKeyboardEvent.kind === ResultKind.MoreChordsNeeded || (resolvedKeyboardEvent.kind === ResultKind.KbFound && resolvedKeyboardEvent.commandId === 'editor.action.showHover' && this._contentWidget?.isVisible));
237237

238238
if (e.keyCode !== KeyCode.Ctrl && e.keyCode !== KeyCode.Alt && e.keyCode !== KeyCode.Meta && e.keyCode !== KeyCode.Shift
239239
&& !mightTriggerFocus) {
@@ -246,7 +246,7 @@ export class ModesHoverController implements IEditorContribution {
246246
if (_sticky) {
247247
return;
248248
}
249-
if ((this._isMouseDown && this._hoverClicked && this._contentWidget?.isColorPickerVisible()) || InlineSuggestionHintsContentWidget.dropDownVisible) {
249+
if ((this._isMouseDown && this._hoverClicked && this._contentWidget?.isColorPickerVisible) || InlineSuggestionHintsContentWidget.dropDownVisible) {
250250
return;
251251
}
252252
this._hoverActivatedByColorDecoratorClick = false;
@@ -262,10 +262,6 @@ export class ModesHoverController implements IEditorContribution {
262262
return this._contentWidget;
263263
}
264264

265-
public isColorPickerVisible(): boolean {
266-
return this._contentWidget?.isColorPickerVisible() || false;
267-
}
268-
269265
public showContentHover(range: Range, mode: HoverStartMode, source: HoverStartSource, focus: boolean, activatedByColorDecoratorClick: boolean = false): void {
270266
this._hoverActivatedByColorDecoratorClick = activatedByColorDecoratorClick;
271267
this._getOrCreateContentWidget().startShowingAtRange(range, mode, source, focus);
@@ -307,8 +303,12 @@ export class ModesHoverController implements IEditorContribution {
307303
this._contentWidget?.goToBottom();
308304
}
309305

310-
public isHoverVisible(): boolean | undefined {
311-
return this._contentWidget?.isVisible();
306+
get isColorPickerVisible(): boolean | undefined {
307+
return this._contentWidget?.isColorPickerVisible;
308+
}
309+
310+
get isHoverVisible(): boolean | undefined {
311+
return this._contentWidget?.isVisible;
312312
}
313313

314314
public dispose(): void {
@@ -372,7 +372,7 @@ class ShowOrFocusHoverAction extends EditorAction {
372372
const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column);
373373
const focus = editor.getOption(EditorOption.accessibilitySupport) === AccessibilitySupport.Enabled || !!args?.focus;
374374

375-
if (controller.isHoverVisible()) {
375+
if (controller.isHoverVisible) {
376376
controller.focus();
377377
} else {
378378
controller.showContentHover(range, HoverStartMode.Immediate, HoverStartSource.Keyboard, focus);

0 commit comments

Comments
 (0)