refactor: move completion replacement logic to editor

This commit is contained in:
CJ van den Berg 2026-01-21 17:35:09 +01:00
parent 77379a58cf
commit d0abaaee2a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 6 additions and 2 deletions

View file

@ -6408,6 +6408,10 @@ pub const Editor = struct {
self.completion_is_complete = is_incomplete;
}
pub fn get_completion_replacement_selection(self: *Self, replace: Selection) ?Selection {
return replace.from_pos(self.buf_root() catch return null, self.metrics);
}
pub fn select(self: *Self, ctx: Context) Result {
var sel: Selection = .{};
if (!try ctx.args.match(.{ tp.extract(&sel.begin.row), tp.extract(&sel.begin.col), tp.extract(&sel.end.row), tp.extract(&sel.end.col) }))

View file

@ -276,7 +276,7 @@ fn get_replace_selection(replace: Buffer.Selection) ?Buffer.Selection {
return if (replace.empty())
null
else if (tui.get_active_editor()) |edt|
replace.from_pos(edt.buf_root() catch return null, edt.metrics)
edt.get_completion_replacement_selection(replace)
else
replace;
}

View file

@ -205,7 +205,7 @@ fn get_replace_selection(replace: Buffer.Selection) ?Buffer.Selection {
return if (replace.empty())
null
else if (tui.get_active_editor()) |edt|
replace.from_pos(edt.buf_root() catch return null, edt.metrics)
edt.get_completion_replacement_selection(replace)
else
replace;
}