agent: use decl-literal init syntax in picker and prompt_assist

This commit is contained in:
Adrià Arrufat
2026-07-15 12:05:34 +02:00
parent b4c971799c
commit 6845c3a542
2 changed files with 6 additions and 6 deletions

View File

@@ -132,10 +132,10 @@ const RawTerminal = struct {
};
fn promptInteractiveChoice(header: []const u8, items: []const [:0]const u8, default: ?usize) !usize {
var raw = try RawTerminal.enable();
var raw: RawTerminal = try .enable();
defer raw.restore();
var state = ChoiceState.init(default);
var state: ChoiceState = .init(default);
const line_count = items.len + 2;
var first_render = true;
while (true) {
@@ -219,7 +219,7 @@ fn readChoiceByte() !?u8 {
}
test "ChoiceState: arrows wrap and enter selects highlighted item" {
var state = ChoiceState.init(null);
var state: ChoiceState = .init(null);
try std.testing.expectEqual(@as(usize, 0), state.selected);
try std.testing.expectEqual(@as(?usize, null), state.apply(.up, 3));
@@ -232,7 +232,7 @@ test "ChoiceState: arrows wrap and enter selects highlighted item" {
}
test "ChoiceState: starts on default and enter returns it" {
var state = ChoiceState.init(2);
var state: ChoiceState = .init(2);
try std.testing.expectEqual(@as(usize, 2), state.selected);
try std.testing.expectEqual(@as(?usize, 2), state.apply(.enter, 3));
}

View File

@@ -436,7 +436,7 @@ fn addPathCompletions(
prefix: []const u8,
buf: *[completion_buf_len:0]u8,
) void {
var matches = PathMatchIterator.init(body) orelse return;
var matches: PathMatchIterator = .init(body) orelse return;
defer matches.deinit();
var name_buf: [completion_buf_len]u8 = undefined;
@@ -613,7 +613,7 @@ fn renderMetaHint(state: *State, meta: *const SlashCommand.MetaCommand, body: []
/// Ghosts the first filesystem entry that completes the partial path `body`.
fn ghostPathFirstMatch(body: []const u8) [*c]const u8 {
var matches = PathMatchIterator.init(body) orelse return null;
var matches: PathMatchIterator = .init(body) orelse return null;
defer matches.deinit();
const m = matches.next() orelse return null;
const suffix: []const u8 = if (m.is_dir) "/" else "";