public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces
@ 2026-01-26 10:45 Chris Idema via GitGitGadget
  2026-01-26 12:15 ` Johannes Sixt
  2026-01-27 20:33 ` [PATCH/RFC v2 0/2] diff.tcl: Fixed " Chris Idema via GitGitGadget
  0 siblings, 2 replies; 30+ messages in thread
From: Chris Idema via GitGitGadget @ 2026-01-26 10:45 UTC (permalink / raw)
  To: git; +Cc: Chris Idema, Chris Idema

From: Chris Idema <github_chris_idema@proton.me>

Tabs were not properly rendered in TK regardless of tab width settings.
Converting tab alignment to spaces before rendering in TK fixes this.
Does not fix alignment issues in gitk.

Signed-off-by: Chris Idema <github_chris_idema@proton.me>
---
    diff.tcl: Fixed alignment of tabs in git-gui diff by using spaces.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2179%2FChrisIdema%2Ffix-gitgui-diff-tab-alignment-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2179/ChrisIdema/fix-gitgui-diff-tab-alignment-v1
Pull-Request: https://github.com/git/git/pull/2179

 git-gui/lib/diff.tcl | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index 442737ba4f..2e13f8c776 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -12,6 +12,27 @@ proc apply_tab_size {{firsttab {}}} {
 	}
 }
 
+proc expand_tabs {line {startcol -1}} {
+	# startcol set to -1, because in preview the lines start with a '+', '-', or ' '
+	global repo_config
+
+	set col $startcol
+	set out ""
+
+	foreach char [split $line ""] {
+		if {$char eq "\t"} {
+			set spaces [expr {$repo_config(gui.tabsize) - ($col % $repo_config(gui.tabsize))}]
+			append out [string repeat " " $spaces]
+			incr col $spaces
+		} else {
+			append out $char
+			incr col
+		}
+	}
+
+	return $out
+}
+
 proc clear_diff {} {
 	global ui_diff current_diff_path current_diff_header
 	global ui_index ui_workdir
@@ -495,7 +516,9 @@ proc read_diff {fd conflict_size cont_info} {
 			}
 		}
 		set mark [$ui_diff index "end - 1 line linestart"]
-		$ui_diff insert end $line $tags
+		set line [expand_tabs $line]
+		$ui_diff insert end "$line" $tags
+
 		if {[string index $line end] eq "\r"} {
 			$ui_diff tag add d_cr {end - 2c}
 		}

base-commit: 1faf5b085a171f9ba9a6d7a446e0de16acccb1dc
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2026-03-04 19:22 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-26 10:45 [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces Chris Idema via GitGitGadget
2026-01-26 12:15 ` Johannes Sixt
2026-01-26 13:32   ` GitHub Chris Idema
2026-01-26 13:59     ` Johannes Sixt
2026-01-26 14:43       ` GitHub Chris Idema
2026-01-26 14:52         ` Johannes Sixt
2026-01-26 15:21           ` GitHub Chris Idema
2026-01-26 15:32           ` GitHub Chris Idema
2026-01-27 20:33 ` [PATCH/RFC v2 0/2] diff.tcl: Fixed " Chris Idema via GitGitGadget
2026-01-27 20:33   ` [PATCH/RFC v2 1/2] diff.tcl: fixed " Chris Idema via GitGitGadget
2026-01-27 20:33   ` [PATCH/RFC v2 2/2] diff.tcl: call "apply_tab_size 1" to fix alignment instead of spaces Chris Idema via GitGitGadget
2026-01-27 22:19     ` Junio C Hamano
2026-01-27 23:26       ` Junio C Hamano
2026-01-28  9:07         ` GitHub Chris Idema
2026-01-28 13:40         ` Johannes Sixt
2026-01-28 14:02           ` GitHub Chris Idema
2026-01-28 15:59             ` Johannes Sixt
2026-01-28 23:42               ` Junio C Hamano
2026-01-29  0:06           ` Junio C Hamano
2026-01-29  8:31             ` GitHub Chris Idema
2026-01-29 10:04               ` Johannes Sixt
2026-01-29 15:17                 ` Junio C Hamano
2026-01-28 10:20   ` [PATCH/RFC v3] diff.tcl: made alignment of tabs in git-gui diff consistent with gitk Chris Idema via GitGitGadget
2026-01-28 17:02     ` Johannes Sixt
2026-01-28 19:02       ` GitHub Chris Idema
2026-01-29  0:02     ` Junio C Hamano
2026-01-29 11:09     ` [PATCH v4] git-gui: shift tabstops to account for the first column of context diffs Chris Idema via GitGitGadget
2026-01-29 21:36       ` Johannes Sixt
2026-03-04 13:32         ` GitHub Chris Idema
2026-03-04 19:22           ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox