refactor: simplify getting the active editor and selection

This commit is contained in:
CJ van den Berg 2024-12-11 20:54:53 +01:00
parent 4b3904d5f2
commit 038ed4da2b
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
10 changed files with 138 additions and 143 deletions

View file

@ -5,7 +5,6 @@ const syntax = @import("syntax");
const Widget = @import("../../Widget.zig");
const tui = @import("../../tui.zig");
const mainview = @import("../../mainview.zig");
pub const Type = @import("palette.zig").Create(@This());
@ -32,9 +31,9 @@ pub fn load_entries(palette: *Type) !usize {
var longest_hint: usize = 0;
var idx: usize = 0;
previous_file_type = blk: {
if (tui.current().mainview.dynamic_cast(mainview)) |mv_| if (mv_.get_editor()) |editor| {
if (editor.syntax) |editor_syntax| break :blk editor_syntax.file_type.name;
};
if (tui.get_active_editor()) |editor|
if (editor.syntax) |editor_syntax|
break :blk editor_syntax.file_type.name;
break :blk null;
};