mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
Adds the optional hover-actions export (plugin API 1.14): plugins contribute a host-rendered action at the left edge of an editor line, revealed by hovering the first four columns of any line in its start-line..end-line range and anchored to its declaration line. The host keeps it left of the line's text, out of the intention bulb's row, never takes focus on hover, collapses several actions into an overflow menu, and lists them in the editor context menu for keyboard access. SDK HoverActions, a minimal fixture, API-compat tests, docs and regenerated components. Review fixes: the button is positioned on its first show (it was left unpositioned until the next mouse move), the styles use theme tokens, the overflow menu is the shared context menu, and the labels go through the text catalog. Co-authored-by: NeverKnowsTomorrow <36879844+NeverKnowsTomorrow@users.noreply.github.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { matchesLine, matchingActions, type PlacedHoverAction } from "./hoverActions";
|
|
|
|
function action(line: number, endLine: number, label: string): PlacedHoverAction {
|
|
return {
|
|
plugin: "test",
|
|
action: {
|
|
line,
|
|
startLine: line,
|
|
endLine,
|
|
icon: "run",
|
|
label,
|
|
tooltip: label,
|
|
command: "run",
|
|
argument: null,
|
|
},
|
|
};
|
|
}
|
|
|
|
describe("inline editor actions", () => {
|
|
it("matches lines inside a method range including the declaration line", () => {
|
|
const outer = action(5, 12, "outer");
|
|
expect(matchesLine(outer.action, 5)).toBe(true);
|
|
expect(matchesLine(outer.action, 9)).toBe(true);
|
|
expect(matchesLine(outer.action, 12)).toBe(true);
|
|
expect(matchesLine(outer.action, 4)).toBe(false);
|
|
expect(matchesLine(outer.action, 13)).toBe(false);
|
|
});
|
|
|
|
it("prefers the innermost overlapping range", () => {
|
|
const outer = action(5, 20, "outer");
|
|
const inner = action(8, 10, "inner");
|
|
expect(matchingActions([outer, inner], 9).map((a) => a.action.label)).toEqual(["inner"]);
|
|
expect(matchingActions([outer, inner], 15).map((a) => a.action.label)).toEqual(["outer"]);
|
|
expect(matchingActions([outer, inner], 30)).toEqual([]);
|
|
});
|
|
});
|