refactor: call insert trigger commands when a single trigger char is inserted
This commit is contained in:
parent
10e9348901
commit
d711279938
1 changed files with 10 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue