Skip to content

Commit a28db3e

Browse files
committed
adding the initial code for just the resizing without the persisting
1 parent 8220e28 commit a28db3e

File tree

3 files changed

+21
-293
lines changed

3 files changed

+21
-293
lines changed

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

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2323
import { AsyncIterableObject } from 'vs/base/common/async';
2424
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
2525
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
26-
import { MultiplePersistedSizeResizableContentWidget } from 'vs/editor/contrib/hover/browser/resizableContentWidget';
26+
import { ResizableContentWidget } from 'vs/editor/contrib/hover/browser/resizableContentWidget';
2727
const $ = dom.$;
2828

2929
export class ContentHoverController extends Disposable {
@@ -389,10 +389,6 @@ export class ContentHoverController extends Disposable {
389389
public escape(): void {
390390
this._widget.escape();
391391
}
392-
393-
public clearPersistedSizes(): void {
394-
this._widget?.clearPersistedSizes();
395-
}
396392
}
397393

398394
class HoverResult {
@@ -450,7 +446,7 @@ const HORIZONTAL_SCROLLING_BY = 30;
450446
const SCROLLBAR_WIDTH = 10;
451447
const SASH_WIDTH_MINUS_BORDER = 3;
452448

453-
export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentWidget {
449+
export class ResizableHoverWidget extends ResizableContentWidget {
454450

455451
public static ID = 'editor.contrib.resizableContentHoverWidget';
456452

@@ -591,10 +587,6 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
591587
return this._positionPreference === ContentWidgetPositionPreference.ABOVE ? this._availableVerticalSpaceAbove(position) : this._availableVerticalSpaceBelow(position);
592588
}
593589

594-
private _findAvailableSpaceHorizontally(): number | undefined {
595-
return this._findMaximumRenderingWidth();
596-
}
597-
598590
private _findMaximumRenderingHeight(): number | undefined {
599591
const availableSpace = this._findAvailableSpaceVertically();
600592
if (!availableSpace) {
@@ -677,9 +669,7 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
677669
}
678670

679671
private _getWidgetHeight(): number {
680-
const containerDomNode = this._hoverWidget.containerDomNode;
681-
const persistedSize = this.findPersistedSize();
682-
return persistedSize ? persistedSize.height : containerDomNode.clientHeight + 2 * SASH_WIDTH_MINUS_BORDER;
672+
return this._hoverWidget.containerDomNode.clientHeight + 2 * SASH_WIDTH_MINUS_BORDER;
683673
}
684674

685675
private _layoutContentWidget(): void {
@@ -688,9 +678,8 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
688678
}
689679

690680
private _updateContentsDomNodeMaxDimensions() {
691-
const persistedSize = this.findPersistedSize();
692-
const width = persistedSize ? 'none' : Math.max(this._editor.getLayoutInfo().width * 0.66, 500);
693-
const height = persistedSize ? 'none' : Math.max(this._editor.getLayoutInfo().height / 4, 250);
681+
const width = Math.max(this._editor.getLayoutInfo().width * 0.66, 500);
682+
const height = Math.max(this._editor.getLayoutInfo().height / 4, 250);
694683
this._setContentsDomNodeMaxDimensions(width, height);
695684
}
696685

@@ -753,22 +742,10 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
753742
}
754743

755744
private _setPersistedHoverDimensionsOrRenderNormally(): void {
756-
let width: number | string;
757-
let height: number | string;
758-
const persistedSize = this.findPersistedSize();
759-
// Suppose a persisted size is defined
760-
if (persistedSize) {
761-
const totalBorderWidth = 2 * SASH_WIDTH_MINUS_BORDER;
762-
width = Math.min(this._findAvailableSpaceHorizontally() ?? Infinity, persistedSize.width - totalBorderWidth);
763-
height = Math.min(this._findAvailableSpaceVertically() ?? Infinity, persistedSize.height - totalBorderWidth);
764-
} else {
765-
// Added because otherwise the initial size of the hover content is smaller than should be
766-
const layoutInfo = this._editor.getLayoutInfo();
767-
this._resizableNode.layout(layoutInfo.height, layoutInfo.width);
768-
width = 'auto';
769-
height = 'auto';
770-
}
771-
this._setHoverWidgetDimensions(width, height);
745+
// Added because otherwise the initial size of the hover content is smaller than should be
746+
const layoutInfo = this._editor.getLayoutInfo();
747+
this._resizableNode.layout(layoutInfo.height, layoutInfo.width);
748+
this._setHoverWidgetDimensions('auto', 'auto');
772749
}
773750

774751
private _setContainerAbsolutePosition(top: number, left: number): void {

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,6 @@ export class ModesHoverController implements IEditorContribution {
286286
return this._contentWidget?.isVisible();
287287
}
288288

289-
public clearPersistedSizes(): void {
290-
this._contentWidget?.clearPersistedSizes();
291-
}
292-
293289
public dispose(): void {
294290
this._unhookEvents();
295291
this._toUnhook.dispose();
@@ -675,31 +671,6 @@ class EscapeFocusHoverAction extends EditorAction {
675671
}
676672
}
677673

678-
class ClearPersistedHoverSizes extends EditorAction {
679-
680-
constructor() {
681-
super({
682-
id: 'editor.action.clearPersistedHoverSizes',
683-
label: nls.localize({
684-
key: 'clearPersistedHoverSizes',
685-
comment: [
686-
'Action that allows to clear the persisted hover sizes.'
687-
]
688-
}, "Clear Persisted Hover Sizes"),
689-
alias: 'Clear Persisted Hover Sizes',
690-
precondition: undefined
691-
});
692-
}
693-
694-
public run(_accessor: ServicesAccessor, editor: ICodeEditor): void {
695-
const controller = ModesHoverController.get(editor);
696-
if (!controller) {
697-
return;
698-
}
699-
controller.clearPersistedSizes();
700-
}
701-
}
702-
703674
registerEditorContribution(ModesHoverController.ID, ModesHoverController, EditorContributionInstantiation.BeforeFirstInteraction);
704675
registerEditorAction(ShowOrFocusHoverAction);
705676
registerEditorAction(ShowDefinitionPreviewHoverAction);
@@ -712,7 +683,6 @@ registerEditorAction(PageDownHoverAction);
712683
registerEditorAction(GoToTopHoverAction);
713684
registerEditorAction(GoToBottomHoverAction);
714685
registerEditorAction(EscapeFocusHoverAction);
715-
registerEditorAction(ClearPersistedHoverSizes);
716686
HoverParticipantRegistry.register(MarkdownHoverParticipant);
717687
HoverParticipantRegistry.register(MarkerHoverParticipant);
718688

0 commit comments

Comments
 (0)