refactor: convert editor.filter.whole_file to an ArrayListUnmanaged
This commit is contained in:
parent
9023109b21
commit
bbdb1c445f
1 changed files with 4 additions and 4 deletions
|
@ -285,7 +285,7 @@ pub const Editor = struct {
|
||||||
pos: CurSel,
|
pos: CurSel,
|
||||||
old_primary: CurSel,
|
old_primary: CurSel,
|
||||||
old_primary_reversed: bool,
|
old_primary_reversed: bool,
|
||||||
whole_file: ?std.ArrayList(u8),
|
whole_file: ?std.ArrayListUnmanaged(u8),
|
||||||
bytes: usize = 0,
|
bytes: usize = 0,
|
||||||
chunks: usize = 0,
|
chunks: usize = 0,
|
||||||
eol_mode: Buffer.EolMode = .lf,
|
eol_mode: Buffer.EolMode = .lf,
|
||||||
|
@ -5540,7 +5540,7 @@ pub const Editor = struct {
|
||||||
.pos = .{ .cursor = sel.begin },
|
.pos = .{ .cursor = sel.begin },
|
||||||
.old_primary = primary.*,
|
.old_primary = primary.*,
|
||||||
.old_primary_reversed = reversed,
|
.old_primary_reversed = reversed,
|
||||||
.whole_file = if (primary.selection) |_| null else std.ArrayList(u8).init(self.allocator),
|
.whole_file = if (primary.selection) |_| null else .empty,
|
||||||
};
|
};
|
||||||
errdefer self.filter_deinit();
|
errdefer self.filter_deinit();
|
||||||
const state = &self.filter_.?;
|
const state = &self.filter_.?;
|
||||||
|
@ -5564,7 +5564,7 @@ pub const Editor = struct {
|
||||||
errdefer self.filter_deinit();
|
errdefer self.filter_deinit();
|
||||||
const buf_a_ = try self.buf_a();
|
const buf_a_ = try self.buf_a();
|
||||||
if (state.whole_file) |*buf| {
|
if (state.whole_file) |*buf| {
|
||||||
try buf.appendSlice(bytes);
|
try buf.appendSlice(self.allocator, bytes);
|
||||||
} else {
|
} else {
|
||||||
const cursor = &state.pos.cursor;
|
const cursor = &state.pos.cursor;
|
||||||
cursor.row, cursor.col, state.work_root = try state.work_root.insert_chars(cursor.row, cursor.col, bytes, buf_a_, self.metrics);
|
cursor.row, cursor.col, state.work_root = try state.work_root.insert_chars(cursor.row, cursor.col, bytes, buf_a_, self.metrics);
|
||||||
|
@ -5629,7 +5629,7 @@ pub const Editor = struct {
|
||||||
|
|
||||||
fn filter_deinit(self: *Self) void {
|
fn filter_deinit(self: *Self) void {
|
||||||
const state = if (self.filter_) |*s| s else return;
|
const state = if (self.filter_) |*s| s else return;
|
||||||
if (state.whole_file) |*buf| buf.deinit();
|
if (state.whole_file) |*buf| buf.deinit(self.allocator);
|
||||||
self.filter_ = null;
|
self.filter_ = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue