Skip to content
Draft

Alt fix #288518

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/vs/base/browser/ui/contextview/contextview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export const enum LayoutAnchorPosition {

export enum LayoutAnchorMode {
AVOID,
ALIGN
ALIGN,
OVERLAP_OKAY
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new OVERLAP_OKAY enum value lacks documentation explaining its purpose and when it should be used, unlike the other layout modes. Consider adding a comment to describe when this mode is appropriate, especially given that it changes the layout behavior to prefer overlapping the anchor rather than flipping to the other side.

Copilot uses AI. Check for mistakes.
}

export interface ILayoutAnchor {
Expand All @@ -116,7 +117,7 @@ export function layout(viewportSize: number, viewSize: number, anchor: ILayoutAn
return layoutAfterAnchorBoundary; // happy case, lay it out after the anchor
}

if (viewSize <= layoutBeforeAnchorBoundary) {
if (viewSize <= layoutBeforeAnchorBoundary && anchor.mode !== LayoutAnchorMode.OVERLAP_OKAY) {
return layoutBeforeAnchorBoundary - viewSize; // ok case, lay it out before the anchor
}

Expand All @@ -126,7 +127,7 @@ export function layout(viewportSize: number, viewSize: number, anchor: ILayoutAn
return layoutBeforeAnchorBoundary - viewSize; // happy case, lay it out before the anchor
}

if (viewSize <= viewportSize - layoutAfterAnchorBoundary) {
if (viewSize <= viewportSize - layoutAfterAnchorBoundary && anchor.mode !== LayoutAnchorMode.OVERLAP_OKAY) {
return layoutAfterAnchorBoundary; // ok case, lay it out after the anchor
}

Expand Down Expand Up @@ -320,7 +321,7 @@ export class ContextView extends Disposable {

const activeWindow = DOM.getActiveWindow();
if (anchorAxisAlignment === AnchorAxisAlignment.VERTICAL) {
const verticalAnchor: ILayoutAnchor = { offset: around.top - activeWindow.pageYOffset, size: around.height, position: anchorPosition === AnchorPosition.BELOW ? LayoutAnchorPosition.Before : LayoutAnchorPosition.After };
const verticalAnchor: ILayoutAnchor = { offset: around.top - activeWindow.pageYOffset, size: around.height, position: anchorPosition === AnchorPosition.BELOW ? LayoutAnchorPosition.Before : LayoutAnchorPosition.After, mode: LayoutAnchorMode.OVERLAP_OKAY };
const horizontalAnchor: ILayoutAnchor = { offset: around.left, size: around.width, position: anchorAlignment === AnchorAlignment.LEFT ? LayoutAnchorPosition.Before : LayoutAnchorPosition.After, mode: LayoutAnchorMode.ALIGN };

top = layout(activeWindow.innerHeight, viewSizeHeight, verticalAnchor) + activeWindow.pageYOffset;
Expand Down
6 changes: 6 additions & 0 deletions src/vs/base/test/browser/ui/contextview/contextview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ suite('Contextview', function () {
assert.strictEqual(layout(200, 20, { offset: 150, size: 50, position: LayoutAnchorPosition.After }), 130);
});

test('layout large hover', () => {
// When the view is large and almost fits on the preferred side, we should prefer to shift it
// rather than flip it to the other side which might be far away.
assert.strictEqual(layout(1084, 306, { offset: 296, size: 2, position: LayoutAnchorPosition.After }), 0);
Comment on lines +30 to +33
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't include the mode parameter in the anchor object, so it's testing the default AVOID behavior rather than the new OVERLAP_OKAY behavior that was introduced. To properly test the "shift rather than flip" behavior described in the comment, the test should specify mode: LayoutAnchorMode.OVERLAP_OKAY in the anchor object. Otherwise, the existing logic would flip to the other side rather than overlap.

Copilot uses AI. Check for mistakes.
});

ensureNoDisposablesAreLeakedInTestSuite();
});
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,19 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer<IAgentSes
// Title
lines.push(`**${session.label}**`);

lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');

Comment on lines +363 to +375
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be debugging/test code that should not be committed. These 12 lines adding 'more' to the tooltip will result in unexpected UI behavior where tooltips display repeated "more" text. This should be removed before merging.

Suggested change
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');

Copilot uses AI. Check for mistakes.
// Tooltip (from provider)
if (session.tooltip) {
const tooltip = typeof session.tooltip === 'string' ? session.tooltip : session.tooltip.value;
Expand Down
Loading