refactor: add selection_pos_to_width and get_replace_selection functions

This commit is contained in:
CJ van den Berg 2025-10-02 16:27:16 +02:00
parent 390fbd51ff
commit 6ae176a8ac
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 14 additions and 0 deletions

View file

@ -5602,6 +5602,11 @@ pub const Editor = struct {
}
}
pub fn selection_pos_to_width(self: *Self, sel_: Selection) ?Selection {
const root = self.buf_root() catch return null;
return sel_.from_pos(root, self.metrics) catch null;
}
fn count_lines(content: []const u8) struct { usize, usize } {
var pos = content;
var offset = content.len;