refactor: implement completion_insert_mode .insert

This commit is contained in:
CJ van den Berg 2026-01-21 17:40:37 +01:00
parent 9729bae7be
commit 3051cc3b86
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -6409,7 +6409,16 @@ pub const Editor = struct {
} }
pub fn get_completion_replacement_selection(self: *Self, replace: Selection) ?Selection { pub fn get_completion_replacement_selection(self: *Self, replace: Selection) ?Selection {
return replace.from_pos(self.buf_root() catch return null, self.metrics); var sel = replace.from_pos(self.buf_root() catch return null, self.metrics);
sel.normalize();
const cursor = self.get_primary().cursor;
return switch (tui.config().completion_insert_mode) {
.insert => if (self.get_primary().cursor.within(sel))
.{ .begin = sel.begin, .end = cursor }
else
sel,
.replace => sel,
};
} }
pub fn select(self: *Self, ctx: Context) Result { pub fn select(self: *Self, ctx: Context) Result {