diff --git a/src/tui/editor.zig b/src/tui/editor.zig index e037cfb..31635aa 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2843,6 +2843,7 @@ pub const Editor = struct { cursor.row, cursor.col, root_ = try root_.insert_chars(cursor.row, cursor.col, s, allocator, self.metrics); cursor.target = cursor.col; self.nudge_insert(.{ .begin = begin, .end = cursor.* }, cursel, s.len); + if (s.len == 1) self.run_insert_triggers(s[0]); return root_; } @@ -6216,6 +6217,15 @@ pub const Editor = struct { return false; } + pub fn run_insert_triggers(self: *Self, char: u8) void { + switch (char) { + '\n', '\t', ' ' => return, + else => {}, + } + for (self.insert_triggers.items) |item| if (item.char == char) + tp.self_pid().send(.{ "cmd", item.command, .{[_]u8{char}} }) catch {}; + } + pub fn add_completion(self: *Self, row: usize, col: usize, is_incomplete: bool, msg: tp.message) Result { if (!(row == self.completion_row and col == self.completion_col)) { self.completions.clearRetainingCapacity();