Commit 958da37b authored by Jonas Bernoulli's avatar Jonas Bernoulli

Use correct width for leading tabs in diffs

An added line like                   |<tab-><tab->text
should be displayed in a diff as     |+<tab-><tab->text
but the display engine turns it into |+<tab><tab->text

We have to set the `:width' of each leading tab individually to
prevent that.

Closes #3185.
parent fef502f0
......@@ -99,6 +99,12 @@ Changes since v2.11.0
tracked use the `--full-history' argument. Otherwise no history at
all would be show. #3012
* Leading tabs in files no longer cause misalignment in diffs. This
is done by overriding the mechanism used by the display engine to
determine how width a tab should be, which doesn't work when there
are additional characters before the "leading" tabs that should
count as an additional, but very short tab-stop. #3185
Fixes since v2.11.0
......@@ -2279,16 +2279,27 @@ are highlighted."
(`(">" nil) nil)))
((looking-at (if merging "^\\(\\+\\| \\+\\)" "^\\+"))
(magit-diff-paint-tab merging)
(magit-diff-paint-whitespace merging)
(or stage
(if highlight 'magit-diff-added-highlight 'magit-diff-added)))
((looking-at (if merging "^\\(-\\| -\\)" "^-"))
(magit-diff-paint-tab merging)
(if highlight 'magit-diff-removed-highlight 'magit-diff-removed))
(magit-diff-paint-tab merging)
(if highlight 'magit-diff-context-highlight 'magit-diff-context))))
(magit-diff-update-hunk-refinement section))
(defun magit-diff-paint-tab (merging)
(forward-char (if merging 2 1))
(while (= (char-after) ?\t)
(put-text-property (point) (1+ (point))
'display (list (list 'space :width tab-width)))
(defun magit-diff-paint-whitespace (merging)
(when (and magit-diff-paint-whitespace
(or (derived-mode-p 'magit-status-mode)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment