Skip to content

[BUG] De-activating 'Ignore All Whitespace Changes' will not always correctly refresh Diff! #1752

@goran-w

Description

@goran-w

Issue 1:

There are currently cases where de-activating the 'Ignore All Whitespace Changes' (toggle-button) option doesn't refresh the Diff view correctly, but if we thereafter switch the selection away from the changed file and then back to it again it DOES refresh (with different contents).

In these cases, after de-activating the option, the Diff view still says "NO CHANGES OR ONLY EOL CHANGES" while the correct behavior would be to show an actual (whitespace-only) Diff. (Activating the option does NOT have any similar refresh-issues.)

This seems to happen when the number of lines in the Diff is the same, regardless of the ignore-whitespace option.

I can easily reproduce this issue when either (or both) of these types of changes are the only ones made in the file :

  • Add/remove space characters on lines in the file.
  • Change line-endings in the file between LF and CR+LF.

However, as soon as I add/remove a line-break, toggling the ignore-whitespace option starts behaving as expected.

Related issue 2:

Adding whitespace within a "word" (splitting the word) and removing whitespace between two "words" (joining the words) should NOT be considered a whitespace-change, since it changes the syntax / semantics of code / text!

In other words, only "whitespace-to-whitespace" changes should be considered "ignoreable"...

To correct this, the --ignore-all-space flag should be replaced by --ignore-space-change!

Related issue 3:

When 'Ignore All Whitespace Changes' is active, if there are both (any number of) whitespace/EOL-only changes and a single 'hunk' of non-whitespace/EOL changes, doing Discard on this hunk will Discard the whole file!

This, to me, feels unexpected - without the ignore-whitespace option this Diff would have displayed one or more other hunks (or a larger hunk) for the whitespace/EOL-changes, and I don't expect these changes to be discarded too (since I'm "presumably" discarding ONLY a specific "semantic" change and not all the other changes that are actually present in the file, even though they are not shown).

(Slightly) Related issue 4:

If the previous version of a file did not have an EOL on its last line, and we add an EOL there, this becomes indicated by a red circular stop-icon in the left-side "before" diff-pane (in side-by-side mode, and only visible when NOT ignoring whitespace).

Apparently, we can't Discard the resulting hunk at the very bottom of the file IF there are other hunks in the same file!

(NOTE: Stage / Unstage can be done on this problematic hunk without issues.)

However, if we first Discard ALL other hunks in the file, THEN we can also Discard this EOL-addition hunk at the very bottom of the file.

Interestingly, in an "inverse" situation where the previous version of a file DID have an EOL on its last line, and we remove that EOL (as indicated by a red circular stop-icon in the right-side "after" diff-pane), then the resulting hunk does NOT have any issue with Discard (even when it's the single hunk in the file).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions