mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-29 09:09:03 +01:00
Cleaning the code, using getters instead
This commit is contained in:
@@ -60,7 +60,7 @@ export class ColorContribution extends Disposable implements IEditorContribution
|
||||
if (!hoverController) {
|
||||
return;
|
||||
}
|
||||
if (!hoverController.isColorPickerVisible()) {
|
||||
if (!hoverController.isColorPickerVisible) {
|
||||
const range = new Range(target.range.startLineNumber, target.range.startColumn + 1, target.range.endLineNumber, target.range.endColumn + 1);
|
||||
hoverController.showContentHover(range, HoverStartMode.Immediate, HoverStartSource.Mouse, false, true);
|
||||
}
|
||||
|
||||
@@ -215,22 +215,26 @@ export class ContentHoverController extends Disposable {
|
||||
this._setCurrentResult(null);
|
||||
}
|
||||
|
||||
public isColorPickerVisible(): boolean {
|
||||
get isColorPickerVisible(): boolean {
|
||||
return this._widget.isColorPickerVisible;
|
||||
}
|
||||
|
||||
public isVisibleFromKeyboard(): boolean {
|
||||
get isVisibleFromKeyboard(): boolean {
|
||||
return this._widget.isVisibleFromKeyboard;
|
||||
}
|
||||
|
||||
public isVisible(): boolean {
|
||||
get isVisible(): boolean {
|
||||
return this._widget.isVisible;
|
||||
}
|
||||
|
||||
public isFocused(): boolean {
|
||||
get isFocused(): boolean {
|
||||
return this._widget.isFocused;
|
||||
}
|
||||
|
||||
get isResizing(): boolean {
|
||||
return this._widget.isResizing;
|
||||
}
|
||||
|
||||
public containsNode(node: Node | null | undefined): boolean {
|
||||
return (node ? this._widget.getDomNode().contains(node) : false);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
private _onEditorMouseMove(mouseEvent: IEditorMouseEvent): void {
|
||||
const target = mouseEvent.target;
|
||||
|
||||
if (this._contentWidget?.isFocused() || this._contentWidget?.widget.isResizing) {
|
||||
if (this._contentWidget?.isFocused || this._contentWidget?.isResizing) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
|
||||
if (
|
||||
!this._isHoverSticky && target.type === MouseTargetType.CONTENT_WIDGET && target.detail === ContentHoverWidget.ID
|
||||
&& this._contentWidget?.isColorPickerVisible()
|
||||
&& this._contentWidget?.isColorPickerVisible
|
||||
) {
|
||||
// though the hover is not sticky, the color picker needs to.
|
||||
return;
|
||||
@@ -186,7 +186,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._isHoverSticky && this._contentWidget?.isVisibleFromKeyboard()) {
|
||||
if (this._isHoverSticky && this._contentWidget?.isVisibleFromKeyboard) {
|
||||
// Sticky mode is on and the hover has been shown via keyboard
|
||||
// so moving the mouse has no effect
|
||||
return;
|
||||
@@ -233,7 +233,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
|
||||
const resolvedKeyboardEvent = this._keybindingService.softDispatch(e, this._editor.getDomNode());
|
||||
// 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
|
||||
const mightTriggerFocus = (resolvedKeyboardEvent.kind === ResultKind.MoreChordsNeeded || (resolvedKeyboardEvent.kind === ResultKind.KbFound && resolvedKeyboardEvent.commandId === 'editor.action.showHover' && this._contentWidget?.isVisible()));
|
||||
const mightTriggerFocus = (resolvedKeyboardEvent.kind === ResultKind.MoreChordsNeeded || (resolvedKeyboardEvent.kind === ResultKind.KbFound && resolvedKeyboardEvent.commandId === 'editor.action.showHover' && this._contentWidget?.isVisible));
|
||||
|
||||
if (e.keyCode !== KeyCode.Ctrl && e.keyCode !== KeyCode.Alt && e.keyCode !== KeyCode.Meta && e.keyCode !== KeyCode.Shift
|
||||
&& !mightTriggerFocus) {
|
||||
@@ -246,7 +246,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
if (_sticky) {
|
||||
return;
|
||||
}
|
||||
if ((this._isMouseDown && this._hoverClicked && this._contentWidget?.isColorPickerVisible()) || InlineSuggestionHintsContentWidget.dropDownVisible) {
|
||||
if ((this._isMouseDown && this._hoverClicked && this._contentWidget?.isColorPickerVisible) || InlineSuggestionHintsContentWidget.dropDownVisible) {
|
||||
return;
|
||||
}
|
||||
this._hoverActivatedByColorDecoratorClick = false;
|
||||
@@ -262,10 +262,6 @@ export class ModesHoverController implements IEditorContribution {
|
||||
return this._contentWidget;
|
||||
}
|
||||
|
||||
public isColorPickerVisible(): boolean {
|
||||
return this._contentWidget?.isColorPickerVisible() || false;
|
||||
}
|
||||
|
||||
public showContentHover(range: Range, mode: HoverStartMode, source: HoverStartSource, focus: boolean, activatedByColorDecoratorClick: boolean = false): void {
|
||||
this._hoverActivatedByColorDecoratorClick = activatedByColorDecoratorClick;
|
||||
this._getOrCreateContentWidget().startShowingAtRange(range, mode, source, focus);
|
||||
@@ -307,8 +303,12 @@ export class ModesHoverController implements IEditorContribution {
|
||||
this._contentWidget?.goToBottom();
|
||||
}
|
||||
|
||||
public isHoverVisible(): boolean | undefined {
|
||||
return this._contentWidget?.isVisible();
|
||||
get isColorPickerVisible(): boolean | undefined {
|
||||
return this._contentWidget?.isColorPickerVisible;
|
||||
}
|
||||
|
||||
get isHoverVisible(): boolean | undefined {
|
||||
return this._contentWidget?.isVisible;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
@@ -372,7 +372,7 @@ class ShowOrFocusHoverAction extends EditorAction {
|
||||
const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column);
|
||||
const focus = editor.getOption(EditorOption.accessibilitySupport) === AccessibilitySupport.Enabled || !!args?.focus;
|
||||
|
||||
if (controller.isHoverVisible()) {
|
||||
if (controller.isHoverVisible) {
|
||||
controller.focus();
|
||||
} else {
|
||||
controller.showContentHover(range, HoverStartMode.Immediate, HoverStartSource.Keyboard, focus);
|
||||
|
||||
Reference in New Issue
Block a user