Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Trailing whitespace in otherwise empty line is not highlighted #212

Closed
FranklinYu opened this issue May 31, 2020 · 4 comments
Closed

Comments

@FranklinYu
Copy link

Steps to reproduce:

  1. Clone any repository, such as this one.
  2. Edit a file with an empty line on it, such as Cargo.toml.
  3. Add a space (or tab) to the empty line.
  4. git diff

Git raw diff:

diff --git a/Cargo.toml b/Cargo.toml
index 7c7e71f..7330174 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ license = "MIT"
 readme = "README.md"
 repository = "https://github.com/dandavison/delta"
 version = "0.2.0"
-
+
 [[bin]]
 name = "delta"
 path = "src/main.rs"
@@ -36,6 +36,6 @@ default-features = false
 features = ["parsing", "assets", "yaml-load", "dump-load", "regex-onig"]

 [dependencies.error-chain]
-version = "0.12.2"
+version = "0.12.2"
 default-features = false
 features = []

Screenshot of Git raw diff:

image

Screenshot of Delta diff:

image

Note that, as comparison, trailing whitespace is rendered correctly. I would like a whitespace-only line to look the same.

Environments

  • Delta 0.1.1
  • macOS Catalina
  • Git 2.24.3 (macOS built-in version)
@dandavison
Copy link
Owner

Agreed, this needs addressing. Thanks @FranklinYu.

@dandavison
Copy link
Owner

Linking similar bug pointed out by @mk12 in #205 (comment), which is related to this one. diff-so-fancy has markEmptyLines which is relevant.

@dandavison
Copy link
Owner

Thanks again @FranklinYu, the issue with delta failing to highlight added whitespace on a blank line is fixed in master (it was a straight-out bug -- a divide-by-zero when calculating the distance between the two lines in terms of edit operations).

I still need to fix the problem of blank line additions/removals being invisible when there is no background color, perhaps by adding a space. #179 (comment) is relevant (discussion about whether delta can drop the space in the first column that it currently emits as a replacement for the -/+ marker).

@dandavison
Copy link
Owner

Moving remaining discussion to #179

@dandavison dandavison changed the title 🐛 Diff is confusing when the line is whitespace only 🐛 Trailing whitespace in otherwise empty line is not highlighted Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants