diff options
Diffstat (limited to 'src/Query.zig')
| -rw-r--r-- | src/Query.zig | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/src/Query.zig b/src/Query.zig index caf64d54..c1a89164 100644 --- a/src/Query.zig +++ b/src/Query.zig @@ -859,19 +859,14 @@ fn setRows(p: *Pardes, rp: *Pane, out: *std.ArrayList(u8), rows: *std.ArrayList( if (std.mem.eql(u8, content, f.content)) { // Same text: the metadata alone, no undo step, no syntax pass. p.gpa.free(content); - if (locations.equalRows(f.location_rows, meta)) { - locations.freeRows(p.gpa, meta); - } else { - locations.freeRows(p.gpa, f.location_rows); - f.location_rows = meta; - dropHighlights(p, f); - } } else { File.setContent(p, f, content); - locations.freeRows(p.gpa, f.location_rows); - f.location_rows = meta; f.saved_revision = f.revision; } + File.setRows(p, f, meta) catch |err| { + locations.freeRows(p.gpa, meta); + if (p.paneBySerial(rp.serial)) |id| p.reportError(id, "rows", err); + }; if (f.pager_spans.len > 0) p.gpa.free(f.pager_spans); f.pager_spans = &.{}; // The cursor stays where it was typing; on a row that went, the last. @@ -996,24 +991,10 @@ pub fn recolor(p: *Pardes) void { fresh = rows; @memcpy(rows[i].colors[0..got.len], got); } - if (fresh) |rows| { - locations.freeRows(p.gpa, f.location_rows); - f.location_rows = rows; - dropHighlights(p, f); - } + if (fresh) |rows| File.setRows(p, f, rows) catch locations.freeRows(p.gpa, rows); } } -/// The pane's painted colours let go, so the next frame paints them from -/// its rows again: with its text the same, a frame would keep the old ones -/// (refreshHighlights keeps a painting that covers the view). -fn dropHighlights(p: *Pardes, f: *File.State) void { - if (f.highlights.len > 0) p.tree_sitter_gpa.free(f.highlights); - f.highlights = &.{}; - f.highlight_start = 0; - f.syntax_dirty = true; -} - /// The path a row of pane `tp`'s text says: its file's, or `@pN` for a /// text that is no file (a list, a scratch). fn addressOf(arena: std.mem.Allocator, tp: *const Pane) []const u8 { @@ -1910,8 +1891,10 @@ pub fn cancel(p: *Pardes, id: usize) void { } const f = &rp.file.?; File.setContent(p, f, s.content); - locations.freeRows(p.gpa, f.location_rows); - f.location_rows = s.rows; + File.setRows(p, f, s.rows) catch |err| { + locations.freeRows(p.gpa, s.rows); + p.reportError(id, "query", err); + }; p.gpa.free(q.asked); q.asked = s.asked; q.source = s.source; |
