fix: focus editor on gutter click events

This commit is contained in:
CJ van den Berg 2026-01-06 19:22:58 +01:00
parent c1200ac5bd
commit 9b2edba3b4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -34,6 +34,7 @@ highlight: bool,
symbols: bool, symbols: bool,
width: usize = 4, width: usize = 4,
editor: *ed.Editor, editor: *ed.Editor,
editor_widget: ?*const Widget = null,
diff_: diff.AsyncDiffer, diff_: diff.AsyncDiffer,
diff_symbols: std.ArrayList(Symbol), diff_symbols: std.ArrayList(Symbol),
@ -305,7 +306,17 @@ fn render_diagnostic(self: *Self, diag: *const ed.Diagnostic, theme: *const Widg
_ = self.plane.putc(&cell) catch {}; _ = self.plane.putc(&cell) catch {};
} }
fn primary_click(self: *const Self, y_: i32) error{Exit}!bool { fn focus_editor(self: *Self) void {
const editor_widget = self.editor_widget orelse blk: {
const editor_widget = self.parent.get("editor") orelse return;
self.editor_widget = editor_widget;
break :blk editor_widget;
};
_ = tui.set_focus_by_widget(editor_widget);
}
fn primary_click(self: *Self, y_: i32) error{Exit}!bool {
self.focus_editor();
const y = self.editor.plane.abs_y_to_rel(y_); const y = self.editor.plane.abs_y_to_rel(y_);
var line = self.view_top + 1; var line = self.view_top + 1;
line += @intCast(y); line += @intCast(y);
@ -317,7 +328,8 @@ fn primary_click(self: *const Self, y_: i32) error{Exit}!bool {
return true; return true;
} }
fn primary_drag(self: *const Self, y_: i32) error{Exit}!bool { fn primary_drag(self: *Self, y_: i32) error{Exit}!bool {
self.focus_editor();
const y = self.editor.plane.abs_y_to_rel(y_); const y = self.editor.plane.abs_y_to_rel(y_);
try command.executeName("drag_to", command.fmt(.{ y + 1, 0 })); try command.executeName("drag_to", command.fmt(.{ y + 1, 0 }));
return true; return true;