diff options
Diffstat (limited to 'core/File.zig')
| -rw-r--r-- | core/File.zig | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/File.zig b/core/File.zig index 813e172f..01aaeec8 100644 --- a/core/File.zig +++ b/core/File.zig @@ -697,6 +697,9 @@ const swap_min = 64 << 10; /// a new buffer in and gives the old to the journal whole (a swap); an /// undo's swap back hands the buffer it replaces to `kept`. fn edit(p: *Pardes, f: *State, off: usize, len: usize, bytes_in: []const u8, whole: ?[]u8, journaled: bool, kept: ?*[]u8) bool { + // A file at a revision is read-only (jj.zig): a key's splice changes + // nothing (a whole text is the editor's to refuse, edit.zig). + if (whole == null) if (f.output) |o| if (o.from == .revision) return false; const old_len = f.content.len; const new_len = old_len - len + bytes_in.len; const span: Span = .{ .head = off, .tail = old_len - off - len }; @@ -1607,7 +1610,7 @@ pub fn refreshHighlights(p: *Pardes) void { syntax.highlightLocationRows(p.tree_sitter_gpa, f.content, f.location_rows) else syntax.highlightLocations(p.tree_sitter_gpa, f.content, start, end), - else => syntax.highlightFileRange(p.tree_sitter_gpa, f.path, f.content, start, end), + else => syntax.highlightFileRange(p.tree_sitter_gpa, langPath(f), f.content, start, end), }) catch { f.syntax_dirty = false; continue; @@ -1641,7 +1644,13 @@ fn paintAhead(p: *Pardes, pane: *Pane, f: *State) void { const end = @max(start, lineStart(p.gpa, f, f.scroll + (if (seen.dir > 0) 4 * rows else rows) + SYNTAX_CONTEXT_AFTER_ROWS)); // Painted already, as far as that goes. if (f.highlights.len > 0 and start >= f.highlight_start and end <= f.highlight_start + f.highlights.len) return; - Stream.paintAhead(p, pane.serial, f.revision, f.path, f.content, start, end); + Stream.paintAhead(p, pane.serial, f.revision, langPath(f), f.content, start, end); +} + +/// The path a text's language is known by: a file at a revision's +/// (jj.zig) without its `@rev`. +pub fn langPath(f: *const State) []const u8 { + return if (@import("jj.zig").of(f)) |r| r.path else f.path; } pub fn supportsContext(pane: *const Pane) bool { |
