summaryrefslogtreecommitdiff
path: root/src/hunks.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/hunks.zig')
-rw-r--r--src/hunks.zig24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/hunks.zig b/src/hunks.zig
index 8f4b4233..19246392 100644
--- a/src/hunks.zig
+++ b/src/hunks.zig
@@ -331,10 +331,10 @@ fn flush(out: *Out, hunk: *Hunk, memo: *SourceMemo, dir: []const u8) !void {
// has it: the marker coloured, the line as its file's.
for (lines) |line| {
const flag: u8 = switch (line.kind) {
- .added => syntax.diff_added,
- .removed => syntax.diff_removed,
+ .added => syntax.ground_add,
+ .removed => syntax.ground_del,
else => 0,
- } | @as(u8, if (line.kind != .context and !line.paired) syntax.diff_whole else 0);
+ } | @as(u8, if (line.kind != .context and !line.paired) syntax.ground_line else 0);
const text = try std.fmt.allocPrint(arena, "{c}{s}", .{ @as(u8, switch (line.kind) {
.added => '+',
.removed => '-',
@@ -389,10 +389,10 @@ fn inferEdits(arena: std.mem.Allocator, minus: []HunkLine, plus: []HunkLine) !vo
const marks = annotate(pair, &alignment, m.code, plus[j].code) catch continue;
if (marks.distance > max_line_distance) continue;
for (marks.minus) |r| for (m.styles[r[0]..r[1]]) |*b| {
- b.* |= syntax.diff_emph;
+ b.* |= syntax.ground_emph;
};
for (marks.plus) |r| for (plus[j].styles[r[0]..r[1]]) |*b| {
- b.* |= syntax.diff_emph;
+ b.* |= syntax.ground_emph;
};
m.paired = true;
plus[j].paired = true;
@@ -583,7 +583,7 @@ const testing = std.testing;
fn emphasised(line: HunkLine) ![]const u8 {
var out: std.ArrayList(u8) = .empty;
- for (line.code, line.styles) |c, s| try out.append(testing.allocator, if (s & syntax.diff_emph != 0) c else '.');
+ for (line.code, line.styles) |c, s| try out.append(testing.allocator, if (s & syntax.ground_emph != 0) c else '.');
return out.toOwnedSlice(testing.allocator);
}
@@ -653,13 +653,13 @@ test "a diff stacks to a label a hunk and its lines, markers gone, tinted and st
try testing.expectEqual(@as(usize, "nowhere/x.txt:2".len), result.rows[0].location_end);
try testing.expect(result.rows[1].declaration);
const removed = result.rows[3];
- try testing.expect(removed.colors[0] & syntax.diff_removed != 0);
+ try testing.expect(removed.colors[0] & syntax.ground_del != 0);
// Paired with the line it changed: no whole-line tint.
- try testing.expect(removed.colors[0] & syntax.diff_whole == 0);
- try testing.expect(removed.colors[1] & syntax.diff_emph != 0);
- try testing.expect(removed.colors[5] & syntax.diff_emph == 0);
- try testing.expect(result.rows[4].colors[0] & syntax.diff_added != 0);
- try testing.expect(result.rows[2].colors[0] & (syntax.diff_added | syntax.diff_removed) == 0);
+ try testing.expect(removed.colors[0] & syntax.ground_line == 0);
+ try testing.expect(removed.colors[1] & syntax.ground_emph != 0);
+ try testing.expect(removed.colors[5] & syntax.ground_emph == 0);
+ try testing.expect(result.rows[4].colors[0] & syntax.ground_add != 0);
+ try testing.expect(result.rows[2].colors[0] & (syntax.ground_add | syntax.ground_del) == 0);
}
test "a hunk the file has moved since is found where it went, inside its declaration" {