fix: fix tests, change enum fields to lowercase

This commit is contained in:
Alex Bennett
2026-06-07 23:55:47 +08:00
parent 3263ce5122
commit 97777cf5a3
3 changed files with 28 additions and 10 deletions

View File

@@ -4222,8 +4222,8 @@ fn maybePromptClick(self: *Surface) !bool {
// For the event, we always send a left-click press event.
// This matches what Kitty sends.
const key: u8, const y: u32 = switch (v) {
.Absolute => .{ 1, pos_vp.y + 1 },
.Relative => .{ 2, pos_vp.y - prompt_pin.y + 1 },
.absolute => .{ 1, pos_vp.y + 1 },
.relative => .{ 2, pos_vp.y - prompt_pin.y + 1 },
};
var data: termio.Message.WriteReq.Small.Array = undefined;
const resp = try std.fmt.bufPrint(

View File

@@ -1226,7 +1226,7 @@ pub fn semanticPrompt(
// within a prompt area to SGR mouse events and defers to the
// shell to handle them.
if (cmd.readOption(.click_events)) |v| {
screen.semantic_prompt.click = .{ .click_events = v } ;
screen.semantic_prompt.click = .{ .click_events = v };
break :click;
}
@@ -12419,7 +12419,24 @@ test "Terminal: OSC133A click_events=1 sets click to click_events" {
.options_unvalidated = "click_events=1",
});
try testing.expectEqual(.click_events, t.screens.active.semantic_prompt.click);
try testing.expectEqual(Screen.SemanticPrompt.SemanticClick{ .click_events = .absolute }, t.screens.active.semantic_prompt.click);
}
test "Terminal: OSC133A click_events=2 sets click to click_events (relative)" {
const alloc = testing.allocator;
var t = try init(alloc, .{ .cols = 10, .rows = 5 });
defer t.deinit(alloc);
// Verify default state is none
try testing.expectEqual(.none, t.screens.active.semantic_prompt.click);
// OSC 133;A with click_events=2
try t.semanticPrompt(.{
.action = .fresh_line_new_prompt,
.options_unvalidated = "click_events=2",
});
try testing.expectEqual(Screen.SemanticPrompt.SemanticClick{ .click_events = .relative }, t.screens.active.semantic_prompt.click);
}
test "Terminal: OSC133A click_events=0 does not set click_events" {
@@ -12476,7 +12493,7 @@ test "Terminal: OSC133A click_events=1 takes priority over cl" {
});
// click_events should take priority
try testing.expectEqual(.click_events, t.screens.active.semantic_prompt.click);
try testing.expectEqual(Screen.SemanticPrompt.SemanticClick{ .click_events = .absolute }, t.screens.active.semantic_prompt.click);
}
test "Terminal: OSC133A click_events=0 falls back to cl" {

View File

@@ -68,7 +68,7 @@ pub const Command = struct {
// See https://github.com/ghostty-org/ghostty/issues/10865 and
// https://github.com/kovidgoyal/kitty/issues/9500
// for further details.
pub const ClickEvents = enum { Absolute, Relative };
pub const ClickEvents = enum { absolute, relative };
pub const Option = enum {
aid,
@@ -211,8 +211,8 @@ pub const Option = enum {
else
null,
.click_events => if (value.len == 1) switch (value[0]) {
'1' => .Absolute,
'2' => .Relative,
'1' => .absolute,
'2' => .relative,
else => null,
} else null,
.special_key => if (value.len == 1) switch (value[0]) {
@@ -1264,9 +1264,10 @@ test "Option.read special_key" {
test "Option.read click_events" {
const testing = std.testing;
try testing.expect(Option.click_events.read("click_events=1").? == true);
try testing.expect(Option.click_events.read("click_events=0").? == false);
try testing.expect(Option.click_events.read("click_events=yes") == null);
try testing.expect(Option.click_events.read("click_events=0") == null);
try testing.expect(Option.click_events.read("click_events=1").? == .absolute);
try testing.expect(Option.click_events.read("click_events=2").? == .relative);
}
test "Option.read exit_code" {