parent
79369bf2ca
commit
2d65864e74
1 changed files with 20 additions and 4 deletions
|
|
@ -1837,10 +1837,26 @@ pub const Editor = struct {
|
||||||
var old = self.cursels;
|
var old = self.cursels;
|
||||||
defer old.deinit(self.allocator);
|
defer old.deinit(self.allocator);
|
||||||
self.cursels = CurSel.List.initCapacity(self.allocator, old.items.len) catch return;
|
self.cursels = CurSel.List.initCapacity(self.allocator, old.items.len) catch return;
|
||||||
for (old.items[0 .. old.items.len - 1], 0..) |*a_, i| if (a_.*) |*a| {
|
var a_idx = old.items.len - 1;
|
||||||
for (old.items[i + 1 ..], i + 1..) |*b_, j| if (b_.*) |*b| {
|
while (a_idx > 0) : (a_idx -= 1) if (old.items[a_idx]) |*a| {
|
||||||
if (a.cursor.eql(b.cursor))
|
var b_idx = a_idx - 1;
|
||||||
old.items[j] = null;
|
while (true) : ({
|
||||||
|
if (b_idx == 0) break else b_idx -= 1;
|
||||||
|
}) if (old.items[b_idx]) |*b| {
|
||||||
|
const b_cursor = b.cursor;
|
||||||
|
if (b.selection) |b_sel| {
|
||||||
|
if (a.merge(b_sel)) {
|
||||||
|
old.items[b_idx] = null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (a.selection) |*a_sel| if (b_cursor.within(a_sel.*)) {
|
||||||
|
if (b.selection) |b_sel| a_sel.expand(b_sel);
|
||||||
|
old.items[b_idx] = null;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if (a.cursor.eql(b_cursor))
|
||||||
|
old.items[b_idx] = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
for (old.items) |*item_| if (item_.*) |*item| {
|
for (old.items) |*item_| if (item_.*) |*item| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue