Skip to content

Commit d5139f3

Browse files
ChrisIdemaj6t
authored andcommitted
git-gui: shift tabstops to account for the first column of patch text
When reviewing a change before staging, it is desirable to see text after tabstops aligned the same way as in the text editor. However, since there is always an additional character in column one in patch text ('+', '-', or space), the alignment is broken if text before the first tab character is just long enough to push the stop to the next tab position. Commit a43c5f5 (git-gui: add configurable tab size to the diff view, 2012-02-12) added infrastructure that manipulates the tabstop positions of the Tk text widget. However, it does so only when a 3-way diff is shown and only so that it takes into account the one additional markup at the beginning of lines. This only achieved that alignment does not get worse for 3-way diffs compared to regular patch text, but left misaligned text in regular patch text unmodified. Use and modify this infrastructure to shift tabstops by one position for regular patch text and two positions for 3-way diffs. Existing code already resets the tabstops to an unshifted position when contents of untracked files are displayed. Signed-off-by: Chris Idema <github_chris_idema@proton.me> [j6t: extend commit message] Signed-off-by: Johannes Sixt <j6t@kdbg.org>
1 parent 1a729cc commit d5139f3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/diff.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ proc read_diff {fd conflict_size cont_info} {
385385
#
386386
if {[string match {@@@ *} $line]} {
387387
set is_3way_diff 1
388+
apply_tab_size 2
389+
} elseif {[string match {@@ *} $line]} {
388390
apply_tab_size 1
389391
}
390392

0 commit comments

Comments
 (0)