refactor: add Editor.has_secondary_cursors()

This commit is contained in:
CJ van den Berg 2026-01-27 20:28:22 +01:00
parent 52ec22a18c
commit 1b9c718ba7
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -452,6 +452,15 @@ pub const Editor = struct {
if (self.buffer) |p| p.set_meta(meta.written()) catch {};
}
pub fn has_secondary_cursors(self: *const Self) bool {
var count: usize = 0;
for (self.cursels.items) |*cursel_| if (cursel_.*) |_| {
count += 1;
if (count > 1) return true;
};
return false;
}
fn count_cursels(self: *const Self) usize {
var count: usize = 0;
for (self.cursels.items) |*cursel_| if (cursel_.*) |_| {
@ -4864,7 +4873,7 @@ pub const Editor = struct {
try self.insert_cursels(value.text);
const root = try self.buf_root();
if (self.count_cursels() > 1)
if (self.has_secondary_cursors())
return;
self.cancel_all_tabstops();