fix(editor): keep long blame tooltips inside a scroll container (#4741)

Hovering the inline blame label of a commit with a long message spilled the tooltip over the workbench: it had only a max-width, and the shared editor theme never made the hover host a column flex container, so CodeMirror's height cap near the window edge did not clip it. The blame tooltip now caps its height and scrolls inside, and the base editor theme lets hover sections shrink inside the squeezed host (the rules LSP hovers already had).

Co-authored-by: muutot <92625353+muutot@users.noreply.github.com>
This commit is contained in:
Muu
2026-11-20 17:24:40 +08:00
committed by GitHub
co-authored by muutot
parent edc6a522ee
commit 802400c324
4 changed files with 44 additions and 0 deletions
+5
View File
@@ -376,6 +376,11 @@ export const openideaTheme = EditorView.theme({
borderRadius: "var(--radius-popup)",
boxShadow: "var(--shadow-popup)",
},
// Near the window edge CodeMirror caps the hover host's height; its sections then shrink and
// scroll inside the popup instead of running past its border. Content tooltips still carry
// their own `max-height` + `overflow` for the space they get when not squeezed.
".cm-tooltip.cm-tooltip-hover": { display: "flex", flexDirection: "column" },
".cm-tooltip-hover > .cm-tooltip-section": { minHeight: 0, flexShrink: 1 },
".cm-tooltip .cm-tooltip-arrow:before": {
borderTopColor: "var(--border-popup)",
borderBottomColor: "var(--border-popup)",
+29
View File
@@ -0,0 +1,29 @@
import { afterEach, expect, it } from "vitest";
import { EditorState } from "@codemirror/state";
import { EditorView } from "@codemirror/view";
import { openideaTheme } from "./theme";
let view: EditorView | null = null;
afterEach(() => {
view?.destroy();
view = null;
});
it("shrinks hover tooltip sections near the window edge instead of spilling past the popup", () => {
view = new EditorView({
state: EditorState.create({ extensions: [openideaTheme] }),
parent: document.body,
});
// The DOM CodeMirror builds: the hover host wraps one section per tooltip.
const host = document.createElement("div");
host.className = "cm-tooltip cm-tooltip-hover";
const section = document.createElement("div");
section.className = "cm-tooltip-section";
host.appendChild(section);
view.dom.appendChild(host);
const hostStyle = getComputedStyle(host);
expect(hostStyle.display).toBe("flex");
expect(hostStyle.flexDirection).toBe("column");
// `min-height: 0` releases the section from the flex minimum so it can shrink and scroll.
expect(getComputedStyle(section).minHeight).toBe("0px");
});
@@ -484,4 +484,11 @@ describe("current line decoration", () => {
// The visible label is the pointer/click region; the anchor stays zero-width.
expect(inlineBlameTheme['.cm-vcs-inline-blame-inner[role="button"]']).toEqual({ cursor: "pointer" });
});
it("caps the commit tooltip's height and scrolls inside it, so a long message stays on screen", () => {
expect(inlineBlameTheme[".cm-vcs-inline-blame-tooltip"]).toMatchObject({
maxHeight: expect.any(String),
overflow: "auto",
});
});
});
+3
View File
@@ -271,6 +271,9 @@ export const inlineBlameTheme = {
".cm-vcs-inline-blame-tooltip": {
padding: "8px 12px",
maxWidth: "min(70ch, 80vw)",
maxHeight: "min(420px, 55vh)",
overflow: "auto",
overscrollBehavior: "contain",
whiteSpace: "pre-wrap",
overflowWrap: "anywhere",
},