summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 357a6b13..6edf3600 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4790,11 +4790,23 @@ pub const Pane = struct {
/// The one coloring choice keyed on what a pane IS, so the highlight
/// producer (refreshHighlights) and the render pass agree on the algorithm.
- pub const ColorAlgo = enum { none, tty, source, diff };
+ pub const ColorAlgo = enum { none, tty, source, diff, locations };
pub fn colorAlgo(pane: *const Pane) ColorAlgo {
if (pane.isTerminal()) return .tty;
if (pane.file) |f| {
if (std.mem.endsWith(u8, f.path, ".diff") or std.mem.endsWith(u8, f.path, ".patch")) return .diff;
+ // A RENDERING, not a document: +Grep, +Search, +Lsp and their kin
+ // have no language of their own, and their rows quote several at
+ // once. Colour each row by the file its location names instead.
+ // Buffers with no locations in them (+Help, +Config) match nothing
+ // and stay plain, so this needs no table of which origins qualify.
+ //
+ // `saves` is the line between the two: a New scratch and a real
+ // file are output-shaped but ARE documents, with one language and
+ // an edit on every keystroke — they keep `.source`, which is both
+ // right for them and what keeps a megabyte of scratch off the
+ // whole-buffer pass below.
+ if (f.output != null and !output_pane.fileTraits(f.output).saves) return .locations;
return .source;
}
return .none;
@@ -16745,7 +16757,9 @@ pub const Pardes = struct {
// to stay on the right glyph when the emulator and this surface
// disagree about how many columns a cluster is worth.
.tty => if (p.settings.colors) term_pane.recolorAnsi(p, pane, r, tx, tw, body_h, body),
- .source, .diff => {
+ // `.locations` joins them because it feeds the same `f.highlights`
+ // — only the pass that FILLED it differs (refreshHighlights).
+ .source, .diff, .locations => {
const f = &pane.file.?;
file_pane.drawGutter(p, pane, r, tx, tw, body_h, active);
if (p.settings.colors) file_pane.recolorSyntax(p, pane, f, r, tx, tw, body_h);