summaryrefslogtreecommitdiff
path: root/core/File.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 02:03:46 -0300
committerGabriel Schneider <[email protected]>2026-11-21 06:47:11 -0300
commitf9ff1acdf7cebf417a3c74d53f8e2d67cfbdbcc2 (patch)
tree336dcffe051f046e732c41d48e58404f639548b1 /core/File.zig
parent2d25d58f8132c54ca0f853899d6b525c4ae892e4 (diff)
downloadpardes-f9ff1acdf7cebf417a3c74d53f8e2d67cfbdbcc2.tar.gz
pardes-f9ff1acdf7cebf417a3c74d53f8e2d67cfbdbcc2.zip
layers: a file at a revision: the address path@rev and path@rev:line, resolved by a Look anywhere (a file really named so wins; the path must be a file), and At <rev> in a file's pane, open the file as jj has it at that revision in a pane named path@rev, coloured as its file (File.langPath), read-only (File.edit refuses a key's splice, edit.zig a whole text's; a bare Save says so); At in such a pane turns it to another revision in its place, bare it goes back to the file; what jj says is the session machine's: core/jj.zig runs it as a site of the step's tape (Site.jj: jj --ignore-working-copy file show, in the file's directory, the name a literal fileset), on an io of its own (the tape's spawns nothing: its allocator fails), its answer recorded, a replica replaying it and never running jj; jj's refusals in its words (At: Revision `x` doesn't exist, No such path, no jj); tests in a jj repository made in the test's directory: At's open, the read-only edits, the Look at a line, the turn in place, the refusals, and a client that replays the open of path@rev:2 ends with the session's digest; tui core-test 879/1037 (158 skipped); the tip gated whole: core-test 880/1038, shell-test 1080/1083, pane-test 183/184, behaviour-test 275/275 and --replay, process-test 0 of 145 failed, term 17/17, kitty 45/45, addons 5/5, consumer-test, both soaks diverged 0, unequal 0, unlisted 0, corpus through a client 22 scenes, daemon.py far, games, window-clients, clients x5, relink, launch, pair, gui, and --clients x2 on ReleaseSafe, macOS and FreeBSD cross-builds; daemon.py plain on ReleaseSafe times out at pair rows as main itself does (2 of 2 on main)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/File.zig')
-rw-r--r--core/File.zig13
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 {