refactor: convert editor.matches to an ArrayListUnmanaged
This commit is contained in:
parent
99c2e8da4e
commit
12dd1e9c8a
2 changed files with 8 additions and 8 deletions
|
@ -59,7 +59,7 @@ pub const Match = struct {
|
|||
has_selection: bool = false,
|
||||
style: ?Widget.Theme.Style = null,
|
||||
|
||||
const List = std.ArrayList(?Self);
|
||||
const List = std.ArrayListUnmanaged(?Self);
|
||||
const Self = @This();
|
||||
|
||||
pub fn from_selection(sel: Selection) Self {
|
||||
|
@ -454,7 +454,7 @@ pub const Editor = struct {
|
|||
.animation_last_time = time.microTimestamp(),
|
||||
.cursels = CurSel.List.init(allocator),
|
||||
.cursels_saved = CurSel.List.init(allocator),
|
||||
.matches = Match.List.init(allocator),
|
||||
.matches = .empty,
|
||||
.enable_terminal_cursor = tui.config().enable_terminal_cursor,
|
||||
.render_whitespace = from_whitespace_mode(tui.config().whitespace_mode),
|
||||
.diagnostics = .empty,
|
||||
|
@ -469,7 +469,7 @@ pub const Editor = struct {
|
|||
self.diagnostics.deinit(self.allocator);
|
||||
if (self.syntax) |syn| syn.destroy(tui.query_cache());
|
||||
self.cursels.deinit();
|
||||
self.matches.deinit();
|
||||
self.matches.deinit(self.allocator);
|
||||
self.handlers.deinit();
|
||||
self.logger.deinit();
|
||||
if (self.buffer) |p| self.buffer_manager.retire(p, meta.items);
|
||||
|
@ -1749,7 +1749,7 @@ pub const Editor = struct {
|
|||
}
|
||||
|
||||
fn cancel_all_matches(self: *Self) void {
|
||||
self.matches.clearAndFree();
|
||||
self.matches.clearAndFree(self.allocator);
|
||||
}
|
||||
|
||||
pub fn clear_matches(self: *Self) void {
|
||||
|
@ -4993,7 +4993,7 @@ pub const Editor = struct {
|
|||
var match: Match = .{ .begin = .{ .row = begin_line, .col = begin_pos }, .end = .{ .row = end_line, .col = end_pos } };
|
||||
if (match.end.eql(self.get_primary().cursor))
|
||||
match.has_selection = true;
|
||||
(self.matches.addOne() catch return).* = match;
|
||||
(self.matches.addOne(self.allocator) catch return).* = match;
|
||||
}
|
||||
|
||||
fn find_selection_match(self: *const Self, sel: Selection) ?*Match {
|
||||
|
@ -5415,7 +5415,7 @@ pub const Editor = struct {
|
|||
};
|
||||
switch (self.matches.items.len) {
|
||||
0 => {
|
||||
(self.matches.addOne() catch return).* = match;
|
||||
(self.matches.addOne(self.allocator) catch return).* = match;
|
||||
},
|
||||
1 => {
|
||||
self.matches.items[0] = match;
|
||||
|
|
|
@ -88,7 +88,7 @@ fn dump_highlight(self: *Self, range: syntax.Range, scope: []const u8, id: u32,
|
|||
if (self.theme) |theme| match.style = .{ .bg = theme.editor_gutter_modified.fg };
|
||||
switch (self.editor.matches.items.len) {
|
||||
0 => {
|
||||
(self.editor.matches.addOne() catch return).* = match;
|
||||
(self.editor.matches.addOne(self.editor.allocator) catch return).* = match;
|
||||
update_match = .add;
|
||||
},
|
||||
1 => {
|
||||
|
@ -116,7 +116,7 @@ fn dump_highlight(self: *Self, range: syntax.Range, scope: []const u8, id: u32,
|
|||
var match_parent = ed.Match.from_selection(sel_parent);
|
||||
if (self.theme) |theme| match_parent.style = .{ .bg = theme.editor_gutter_added.fg };
|
||||
switch (update_match) {
|
||||
.add => (self.editor.matches.addOne() catch return).* = match_parent,
|
||||
.add => (self.editor.matches.addOne(self.editor.allocator) catch return).* = match_parent,
|
||||
.set => self.editor.matches.items[1] = match_parent,
|
||||
.no => {},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue