diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 15:39:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | c04df904f2fa686cbe5ce0c078a96260af7b08bd (patch) | |
| tree | ebb892b5b2f4c91505c241d1408fea1a1904a883 /docs | |
| parent | b9eefda75ab9a63fc510de781d02b92fc04ad31d (diff) | |
| download | pardes-c04df904f2fa686cbe5ce0c078a96260af7b08bd.tar.gz pardes-c04df904f2fa686cbe5ce0c078a96260af7b08bd.zip | |
A diff reads as the code it changes: hunks in their file's language, added and removed rows tinted
A .diff or .patch pane, and a command pane whose output is a diff (`git
diff`, `git show`, `diff -u`; told by a `diff --git` line, or `---`/`+++`
with a `@@` under them, in its first rows), colour each hunk's code in the
language of the file its section names (`+++ b/<path>`, `--- a/<path>` for
a deleted file), with tree-sitter, as highlightLocations does for results.
src/diff.zig walks a unified diff by its `@@` counts, so a removed line
that reads `--- x` is no header. Each side of a hunk is parsed as one text
(context and removed lines the old side, context and added lines the new),
so a string or comment across lines colours as it does in the file; a side
no line takes its colours from is not parsed. A section's hunks share a
parse, in pieces of about 40 lines (a hunk past 80 is cut), only those in
view, and each piece's colours are kept by its bytes, so scrolling back and
a terminal's every repaint parse nothing again.
Added and removed lines carry a flag in their style byte; the painter tints
their rows to the pane's edge, a little way from the page toward the
theme's ANSI green or red, and draws the prefix in that hue pushed to read
on it. A file in no known language keeps the old line colours.
A command pane is read once its command has finished: its rows are copied
once (File.DiffOutput, dropped when the pane runs again), so no frame dumps
the scrollback, and painted over what git printed. A running command is
shown as it prints.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/tags.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/tags.md b/docs/tags.md index 93c8a6fa..4d4e9178 100644 --- a/docs/tags.md +++ b/docs/tags.md @@ -64,6 +64,20 @@ Unsaved text shows on the pane's grip, as acme's modbutton, not in the tag. In a terminal the grip is two cells: the pane's mode (blank normal, `^` insert, `$` tty mode), then `*` while unsaved. +## Reviewing diffs + +Open a `.diff` or `.patch` file, or run `git diff` (or `git show`, `diff -u +old new`) as a command from any tag: once the command has finished, output +that starts as a diff does (a `diff --git` line, or a `--- ` line with `+++ +` and `@@` under it) is shown as one. Each hunk's code is coloured in the language of the file its +section names (`+++ b/<path>`, or `--- a/<path>` for a deleted file), its +old side (context and removed lines) and new side (context and added lines) +each parsed as one text, so a string or comment across lines colours as it +does in the file. Added and removed rows are tinted to the pane's edge, +their `+`/`-` in the tint's hue (the theme's ANSI green and red where it +has them); a file in no language pardes knows keeps the plain line colours. +Only the hunks in view are parsed, a few dozen lines at a time, each once. + ## Editing tags A tag is text like a body, with the body's normal and insert modes and undo. |
