Skip to content

Commit 8220e28

Browse files
committed
making the code more clear
1 parent b595dd8 commit 8220e28

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class ContentHoverController extends Disposable {
8080
* Returns true if the hover shows now or will show.
8181
*/
8282
public maybeShowAt(mouseEvent: IEditorMouseEvent): boolean {
83-
if (this._widget.resizing) {
83+
if (this._widget.isResizing) {
8484
return true;
8585
}
8686
const anchorCandidates: HoverAnchor[] = [];
@@ -725,7 +725,7 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
725725
this._render(node, hoverData);
726726
const widgetHeight = this._getWidgetHeight();
727727
const widgetPosition = hoverData.showAtPosition;
728-
this._positionPreference = this._findRenderingPreference(widgetHeight, widgetPosition) ?? ContentWidgetPositionPreference.ABOVE;
728+
this._positionPreference = this._findPositionPreference(widgetHeight, widgetPosition) ?? ContentWidgetPositionPreference.ABOVE;
729729
this._setContentPosition(hoverData, this._positionPreference);
730730

731731
// See https://github.com/microsoft/vscode/issues/140339

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class ModesHoverController implements IEditorContribution {
222222

223223
this._hoverClicked = false;
224224
this._glyphWidget?.hide();
225-
if (!this._contentWidget?.widget.resizing) {
225+
if (!this._contentWidget?.widget.isResizing) {
226226
this._contentWidget?.hide();
227227
}
228228
}

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

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,32 @@ abstract class ResizableContentWidget extends Disposable implements IContentWidg
2121
readonly allowEditorOverflow: boolean = true;
2222
readonly suppressMouseDown: boolean = false;
2323

24-
protected readonly _contentNode: HTMLDivElement;
2524
protected readonly _resizableNode = this._register(new ResizableHTMLElement());
2625
protected _contentPosition: IContentWidgetPosition | null = null;
2726

28-
private _resizing: boolean = false;
27+
private _isResizing: boolean = false;
2928

3029
constructor(
3130
protected readonly _editor: ICodeEditor,
3231
_initialSize: dom.IDimension = new dom.Dimension(10, 10)
3332
) {
3433
super();
35-
this._contentNode = document.createElement('div');
36-
this._contentNode.style.width = `${_initialSize.width}px`;
37-
this._contentNode.style.height = `${_initialSize.height}px`;
3834
this._resizableNode.domNode.style.position = 'absolute';
39-
this._resizableNode.domNode.appendChild(this._contentNode);
4035
this._resizableNode.minSize = new dom.Dimension(10, 10);
4136
this._resizableNode.enableSashes(true, true, true, true);
4237
this._resizableNode.layout(_initialSize.height, _initialSize.width);
4338
this._register(this._resizableNode.onDidResize(e => {
44-
this._contentNode.style.width = `${e.dimension.width}px`;
45-
this._contentNode.style.height = `${e.dimension.height}px`;
4639
if (e.done) {
47-
this._resizing = false;
40+
this._isResizing = false;
4841
}
4942
}));
5043
this._register(this._resizableNode.onDidWillResize(() => {
51-
this._resizing = true;
44+
this._isResizing = true;
5245
}));
5346
}
5447

55-
get resizing() {
56-
return this._resizing;
48+
get isResizing() {
49+
return this._isResizing;
5750
}
5851

5952
abstract getId(): string;
@@ -68,11 +61,8 @@ abstract class ResizableContentWidget extends Disposable implements IContentWidg
6861

6962
protected _availableVerticalSpaceAbove(position: IPosition): number | undefined {
7063
const editorDomNode = this._editor.getDomNode();
71-
if (!editorDomNode) {
72-
return;
73-
}
7464
const mouseBox = this._editor.getScrolledVisiblePosition(position);
75-
if (!mouseBox) {
65+
if (!editorDomNode || !mouseBox) {
7666
return;
7767
}
7868
const editorBox = dom.getDomNodePagePosition(editorDomNode);
@@ -81,11 +71,8 @@ abstract class ResizableContentWidget extends Disposable implements IContentWidg
8171

8272
protected _availableVerticalSpaceBelow(position: IPosition): number | undefined {
8373
const editorDomNode = this._editor.getDomNode();
84-
if (!editorDomNode) {
85-
return;
86-
}
8774
const mouseBox = this._editor.getScrolledVisiblePosition(position);
88-
if (!mouseBox) {
75+
if (!editorDomNode || !mouseBox) {
8976
return;
9077
}
9178
const editorBox = dom.getDomNodePagePosition(editorDomNode);
@@ -94,7 +81,7 @@ abstract class ResizableContentWidget extends Disposable implements IContentWidg
9481
return bodyBox.height - mouseBottom;
9582
}
9683

97-
protected _findRenderingPreference(widgetHeight: number, showAtPosition: IPosition): ContentWidgetPositionPreference | undefined {
84+
protected _findPositionPreference(widgetHeight: number, showAtPosition: IPosition): ContentWidgetPositionPreference | undefined {
9885
const maxHeightBelow = Math.min(this._availableVerticalSpaceBelow(showAtPosition) ?? Infinity, widgetHeight);
9986
const maxHeightAbove = Math.min(this._availableVerticalSpaceAbove(showAtPosition) ?? Infinity, widgetHeight);
10087
const maxHeight = Math.min(Math.max(maxHeightAbove, maxHeightBelow), widgetHeight);

0 commit comments

Comments
 (0)