summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLibravatar Bert Wesarg <bert.wesarg@googlemail.com>2010-11-15 11:00:33 +0100
committerLibravatar Pat Thoyts <patthoyts@users.sourceforge.net>2010-11-19 09:32:58 +0000
commit46a0431b996cd19f21e0247c97b1eab2c19698fc (patch)
tree243f99d278f30fbbf4d25a9a3d906f754b138ae4 /lib
parentgit-gui: apply color information from git diff output (diff)
downloadtgif-46a0431b996cd19f21e0247c97b1eab2c19698fc.tar.xz
git-gui: fix ANSI-color parsing
git diff always outputs color reset commands, even when the color for the current part is disabled (ie. normal). But the current ANSI-color parsing code assumes that color start and reset commands appear in matching pairs. Relax this assumption. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/diff.tcl12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/diff.tcl b/lib/diff.tcl
index dcf0711be0..0579fa609d 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -337,12 +337,20 @@ proc parse_color_line {line} {
set result ""
set markup [list]
set regexp {\033\[((?:\d+;)*\d+)?m}
+ set need_reset 0
while {[regexp -indices -start $start $regexp $line match code]} {
foreach {begin end} $match break
append result [string range $line $start [expr {$begin - 1}]]
- lappend markup [string length $result] \
- [eval [linsert $code 0 string range $line]]
+ set pos [string length $result]
+ set col [eval [linsert $code 0 string range $line]]
set start [incr end]
+ if {$col eq "0" || $col eq ""} {
+ if {!$need_reset} continue
+ set need_reset 0
+ } else {
+ set need_reset 1
+ }
+ lappend markup $pos $col
}
append result [string range $line $start end]
if {[llength $markup] < 4} {set markup {}}