ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: underline added/removed lines only in color-words diffs

We don't want e.g. `jj diff --git` to have underlined text because
it's redundant there. This patch fixes that by adding a new `token`
label used only in the color-words diff (for now - it may be used in
git diffs in the future).

This means we could remove the `line_number` label but I left it
because there's little harm in having it and it seems like it can
still be useful.

Thanks to @yuja for noticing and suggesting the fix.
This commit is contained in:
Martin von Zweigbergk 2024-06-26 13:47:00 -07:00 committed by Martin von Zweigbergk
parent 35e0e4d133
commit 848bb610cc
2 changed files with 9 additions and 5 deletions

View file

@ -78,9 +78,9 @@
"diff binary" = "cyan"
"diff file_header" = { bold = true }
"diff hunk_header" = "cyan"
"diff removed" = { fg = "red", underline = true }
"diff added" = { fg = "green", underline = true }
"diff line_number" = { underline = false }
"diff removed" = { fg = "red" }
"diff added" = { fg = "green" }
"diff token" = { underline = true }
"diff modified" = "cyan"
"diff access-denied" = { bg = "red" }

View file

@ -407,10 +407,14 @@ fn show_color_words_diff_line(
let before = data[0];
let after = data[1];
if !before.is_empty() {
formatter.with_label("removed", |formatter| formatter.write_all(before))?;
formatter.with_label("removed", |formatter| {
formatter.with_label("token", |formatter| formatter.write_all(before))
})?;
}
if !after.is_empty() {
formatter.with_label("added", |formatter| formatter.write_all(after))?;
formatter.with_label("added", |formatter| {
formatter.with_label("token", |formatter| formatter.write_all(after))
})?;
}
}
}