From d25669d928c330d86da82f4d650e580dc85d76b6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 5 Dec 2015 13:48:24 +0000 Subject: Fix for bug [1739605] - [text see] misbehaves following widget create/populate - Patch from Koen Danckaert FossilOrigin-Name: ca9fe22e1571676fac126e188f3af5cc8697bffb --- generic/tkTextDisp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cfe6e7a..851e17a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5237,6 +5237,15 @@ TkTextSetYView( } /* + * If the window height is smaller than the line height, prefer to make + * the top of the line visible. + */ + + if (dInfoPtr->maxY - dInfoPtr->y < lineHeight) { + bottomY = lineHeight; + } + + /* * Our job now is to arrange the display so that indexPtr appears as low * on the screen as possible but with its bottom no lower than bottomY. * BottomY is the bottom of the window if the desired line is just below -- cgit v0.12 From 010555966a15663f84c0de817ffe804b0843c0ab Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 6 Dec 2015 19:57:34 +0000 Subject: Added non-regression test case: textDisp-11.21 FossilOrigin-Name: a16263c8e70ec81ee7ac325bbe944671f7aad91c --- tests/textDisp.test | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/textDisp.test b/tests/textDisp.test index 5508d7c..038eccd 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1574,6 +1574,17 @@ test textDisp-11.20 {TkTextSetYView, see in elided lines} { # this shall not crash (null chunkPtr in TkTextSeeCmd is tested) .top.t see 3.0 } {} +test textDisp-11.21 {TkTextSetYView, window height smaller than the line height} { + .top.t delete 1.0 end + for {set i 1} {$i <= 10} {incr i} { + .top.t insert end "Line $i\n" + } + set lineheight [font metrics [.top.t cget -font] -linespace] + wm geometry .top 200x[expr {$lineheight / 2}] + update + .top.t see 1.0 + .top.t index @0,[expr {$lineheight - 2}] +} {1.0} .t configure -wrap word .t delete 50.0 51.0 -- cgit v0.12