From c496046c21dec2ceef5e03a5205ea6d0cc0fde9f Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 28 Dec 2014 15:09:46 +0000 Subject: Fixed Bad counting of the total number of vertical pixels in the text widget, resulting in small change of the Y scrollbar size. Happened because CalculateDisplayLineHeight expects an index at start of a display line, which was not always the case. --- generic/tkTextDisp.c | 14 ++++++++++++++ tests/text.test | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f99ecd8..ae9c341 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3711,6 +3711,20 @@ TkTextUpdateOneLine( } /* + * CalculateDisplayLineHeight _must_ be called (below) with an index at + * the beginning of a display line. Force this to happen. This is needed + * when TkTextUpdateOneLine is called with a line that is merged with its + * previous line: the number of merged logical lines in a display line is + * calculated correctly only when CalculateDisplayLineHeight receives + * an index at the beginning of a display line. In turn this causes the + * merged lines to receive their correct zero pixel height in + * TkBTreeAdjustPixelHeight. + */ + + TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); + linePtr = indexPtr->linePtr; + + /* * Iterate through all display-lines corresponding to the single logical * line 'linePtr' (and lines merged into this line due to eol elision), * adding up the pixel height of each such display line as we go along. diff --git a/tests/text.test b/tests/text.test index 6121b85..e75f38a 100644 --- a/tests/text.test +++ b/tests/text.test @@ -733,6 +733,24 @@ test text-9.2.46 {TextWidgetCmd procedure, "count" option} -setup { } -cleanup { destroy .mytop } -result {1 3} +test text-9.2.47 {TextWidgetCmd procedure, "count" option} -setup { + .t delete 1.0 end + update + set res {} +} -body { + for {set i 1} {$i < 25} {incr i} { + .t insert end "Line $i\n" + } + .t tag configure hidden -elide true + .t tag add hidden 5.7 11.0 + update + set y1 [lindex [.t yview] 1] + .t count -displaylines 5.0 11.0 + set y2 [lindex [.t yview] 1] + .t count -displaylines 5.0 12.0 + set y3 [lindex [.t yview] 1] + list [expr {$y1 == $y2}] [expr {$y1 == $y3}] +} -result {1 1} # Newer tags are higher priority .t tag configure elide1 -elide 0 -- cgit v0.12