summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8f85599)
raw | patch | inline | side by side (parent: 8f85599)
author | Bert Wesarg <bert.wesarg@googlemail.com> | |
Mon, 15 Nov 2010 10:00:33 +0000 (11:00 +0100) | ||
committer | Pat Thoyts <patthoyts@users.sourceforge.net> | |
Fri, 19 Nov 2010 09:32:58 +0000 (09:32 +0000) |
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>
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>
lib/diff.tcl | patch | blob | history |
diff --git a/lib/diff.tcl b/lib/diff.tcl
index dcf0711be0119a8f5ec42b48d97980330f7113b3..0579fa609d191d5dc5244e1f56a3df9daaff9aa3 100644 (file)
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
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 {}}