Skip to content
This repository was archived by the owner on Jul 3, 2026. It is now read-only.

Commit 3cea556

Browse files
committed
feat: Add CodeMirror tooltip space constraint
1 parent f2ac88a commit 3cea556

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/cm/baseExtensions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
highlightSpecialChars,
2020
keymap,
2121
rectangularSelection,
22+
tooltips,
2223
} from "@codemirror/view";
2324

2425
/**
@@ -42,5 +43,17 @@ export default function createBaseExtensions(): Extension[] {
4243
highlightActiveLine(),
4344
highlightSelectionMatches(),
4445
keymap.of([...completionKeymap, ...defaultKeymap, ...historyKeymap]),
46+
// This prevents tooltips from being going out of the editor area
47+
tooltips({
48+
tooltipSpace: (view) => {
49+
const rect = view.dom.getBoundingClientRect();
50+
return {
51+
top: rect.top,
52+
left: rect.left,
53+
bottom: window.innerHeight,
54+
right: window.innerWidth,
55+
};
56+
},
57+
}),
4558
];
4659
}

0 commit comments

Comments
 (0)