summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkTextDisp.c43
-rw-r--r--tests/textDisp.test12
2 files changed, 35 insertions, 20 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 49a35f5..f718e2a 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -5546,32 +5546,35 @@ TkTextSeeCmd(
/*
* Call a chunk-specific function to find the horizontal range of the
- * character within the chunk.
+ * character within the chunk. chunkPtr is NULL if trying to see in elided
+ * region.
*/
- (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount,
- dlPtr->y + dlPtr->spaceAbove,
- dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
- dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width,
- &height);
- delta = x - dInfoPtr->curXPixelOffset;
- oneThird = lineWidth/3;
- if (delta < 0) {
- if (delta < -oneThird) {
- dInfoPtr->newXPixelOffset = (x - lineWidth/2);
- } else {
- dInfoPtr->newXPixelOffset -= ((-delta) );
- }
- } else {
- delta -= (lineWidth - width);
- if (delta > 0) {
- if (delta > oneThird) {
+ if (chunkPtr != NULL) {
+ (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount,
+ dlPtr->y + dlPtr->spaceAbove,
+ dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
+ dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width,
+ &height);
+ delta = x - dInfoPtr->curXPixelOffset;
+ oneThird = lineWidth/3;
+ if (delta < 0) {
+ if (delta < -oneThird) {
dInfoPtr->newXPixelOffset = (x - lineWidth/2);
} else {
- dInfoPtr->newXPixelOffset += (delta );
+ dInfoPtr->newXPixelOffset -= ((-delta) );
}
} else {
- return TCL_OK;
+ delta -= (lineWidth - width);
+ if (delta > 0) {
+ if (delta > oneThird) {
+ dInfoPtr->newXPixelOffset = (x - lineWidth/2);
+ } else {
+ dInfoPtr->newXPixelOffset += (delta );
+ }
+ } else {
+ return TCL_OK;
+ }
}
}
dInfoPtr->flags |= DINFO_OUT_OF_DATE;
diff --git a/tests/textDisp.test b/tests/textDisp.test
index 12a20c6..aed842c 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -1558,6 +1558,18 @@ test textDisp-11.19 {TkTextSetYView, see in elided lines} {
set ind3 [.top.t index @0,0]
list [expr {$ind1 == $ind2}] [expr {$ind1 == $ind3}]
} {1 1}
+test textDisp-11.20 {TkTextSetYView, see in elided lines} {
+ .top.t delete 1.0 end
+ .top.t configure -wrap none
+ for {set i 1} {$i < 5} {incr i} {
+ .top.t insert end [string repeat "Line $i " 50]
+ .top.t insert end "\n"
+ }
+ .top.t delete 3.11 3.14
+ .top.t tag add hidden 3.0 4.0
+ # this shall not crash (null chunkPtr in TkTextSeeCmd is tested)
+ .top.t see 3.0
+} {}
.t configure -wrap word
.t delete 50.0 51.0