refactor: add match_count to overlay/dropdown
This commit is contained in:
parent
d125f69182
commit
41c1e54cac
1 changed files with 5 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ pub fn Create(options: type) type {
|
||||||
menu: *Menu.State(*Self),
|
menu: *Menu.State(*Self),
|
||||||
mode: keybind.Mode,
|
mode: keybind.Mode,
|
||||||
query: std.ArrayList(u8),
|
query: std.ArrayList(u8),
|
||||||
|
match_count: usize,
|
||||||
logger: log.Logger,
|
logger: log.Logger,
|
||||||
longest: usize = 0,
|
longest: usize = 0,
|
||||||
commands: command.Collection(cmds) = undefined,
|
commands: command.Collection(cmds) = undefined,
|
||||||
|
|
@ -86,6 +87,7 @@ pub fn Create(options: type) type {
|
||||||
.noninvasive => "overlay/dropdown-noninvasive",
|
.noninvasive => "overlay/dropdown-noninvasive",
|
||||||
}, allocator, .{}),
|
}, allocator, .{}),
|
||||||
.placement = if (@hasDecl(options, "placement")) options.placement else .top_center,
|
.placement = if (@hasDecl(options, "placement")) options.placement else .top_center,
|
||||||
|
.match_count = 0,
|
||||||
};
|
};
|
||||||
try self.commands.init(self);
|
try self.commands.init(self);
|
||||||
self.mode.event_handler = EventHandler.to_owned(self);
|
self.mode.event_handler = EventHandler.to_owned(self);
|
||||||
|
|
@ -96,6 +98,7 @@ pub fn Create(options: type) type {
|
||||||
try options.load_entries_with_args(self, ctx)
|
try options.load_entries_with_args(self, ctx)
|
||||||
else
|
else
|
||||||
try options.load_entries(self);
|
try options.load_entries(self);
|
||||||
|
self.match_count = self.entries.items.len;
|
||||||
if (@hasDecl(options, "restore_state"))
|
if (@hasDecl(options, "restore_state"))
|
||||||
options.restore_state(self) catch {};
|
options.restore_state(self) catch {};
|
||||||
if (@hasDecl(options, "initial_query")) blk: {
|
if (@hasDecl(options, "initial_query")) blk: {
|
||||||
|
|
@ -290,8 +293,9 @@ pub fn Create(options: type) type {
|
||||||
if (self.items < self.view_rows)
|
if (self.items < self.view_rows)
|
||||||
try options.add_menu_entry(self, entry, null);
|
try options.add_menu_entry(self, entry, null);
|
||||||
}
|
}
|
||||||
|
self.match_count = self.entries.items.len;
|
||||||
} else {
|
} else {
|
||||||
_ = try self.query_entries(self.query.items);
|
self.match_count = try self.query_entries(self.query.items);
|
||||||
}
|
}
|
||||||
if (self.initial_selected) |idx| {
|
if (self.initial_selected) |idx| {
|
||||||
self.initial_selected = null;
|
self.initial_selected = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue