refactor: move completion replacement logic to editor
This commit is contained in:
parent
77379a58cf
commit
d0abaaee2a
3 changed files with 6 additions and 2 deletions
|
|
@ -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) }))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue