sublimehq / sublime_merge

Issue tracker for Sublime Merge
https://www.sublimemerge.com
273 stars 14 forks source link

"Hide whitespace changes" also hides changes inside strings #1741

Open skjasm opened 1 year ago

skjasm commented 1 year ago

Version info

Description

"Hide whitespace changes" also hides whitespace changes inside strings

Steps to reproduce

Steps to reproduce the behavior:

  1. Commit a file containing a string in quotes.
  2. Edit file, add or remove whitespace in the string.
  3. View the edited file in Sublime Merge with "hide whitespace changes enabled".

Expected behavior

I expected "Hide whitespace changes" to hide whitespace changes in code that do not affect the program: spaces around punctuation, indentation in C++. This works.

I expected Sublime Merge to still show all changes that affect the program. Changing the content of a string is always significant, even when the change is only whitespace in the string.

Screenshots

a_demo_1 a_demo_2

jfcherng commented 1 year ago

Nothing in Git is language context-aware, most likely. It's just text.

image

The fancy tool you want is probably https://github.com/Wilfred/difftastic

skjasm commented 1 year ago

Fair enough. SM is at some level aware of what's strings and what's not since it can color syntax, but I guess that information is not available to the diff engine.

jfcherng commented 1 year ago

I think SM doesn't do any diff by itself but just call the git executable. And then color the diff output from git with corresponding syntax definition.