mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-31 17:55:59 -04:00
agent: use decl-literal init syntax in picker and prompt_assist
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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 "";
|
||||
|
||||
Reference in New Issue
Block a user