summaryrefslogtreecommitdiffstats
path: root/generic/tkTextDisp.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-02-09 18:43:52 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-02-09 18:43:52 (GMT)
commit77c0bc32154c03e49b39ad66e676999e29b66a2c (patch)
treeda2ea54eebc27b5b2601fd217019bc0eae04c6c2 /generic/tkTextDisp.c
parentb2bb8f7366e971a698d64610c5d30fa31f414ca1 (diff)
parent8f151700b10bf8811876305e284738707d4ad237 (diff)
downloadtk-77c0bc32154c03e49b39ad66e676999e29b66a2c.zip
tk-77c0bc32154c03e49b39ad66e676999e29b66a2c.tar.gz
tk-77c0bc32154c03e49b39ad66e676999e29b66a2c.tar.bz2
merge trunk
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r--generic/tkTextDisp.c59
1 files changed, 45 insertions, 14 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 18b373f..7969091 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -4869,16 +4869,9 @@ TextRedrawTag(
/*
* Round up the starting position if it's before the first line visible on
- * the screen (we only care about what's on the screen). Beware that the
- * display info structure might need update, for instance if we arrived
- * here from an 'after idle' script removing tags in a range whose
- * display lines (and dInfo) were partially invalidated by a previous
- * delete operation in the text widget.
+ * the screen (we only care about what's on the screen).
*/
- if (dInfoPtr->flags & DINFO_OUT_OF_DATE) {
- UpdateDisplayInfo(textPtr);
- }
dlPtr = dInfoPtr->dLinePtr;
if (dlPtr == NULL) {
return;
@@ -5240,7 +5233,10 @@ TkTextSetYView(
dInfoPtr->newTopPixelOffset = 0;
goto scheduleUpdate;
- }
+ }
+ /*
+ * The line is already on screen, with no need to scroll.
+ */
return;
}
}
@@ -6703,6 +6699,7 @@ FindDLine(
const TkTextIndex *indexPtr)/* Index of desired character. */
{
DLine *dlPtrPrev;
+ TkTextIndex indexPtr2;
if (dlPtr == NULL) {
return NULL;
@@ -6727,24 +6724,58 @@ FindDLine(
dlPtrPrev = dlPtr;
dlPtr = dlPtr->nextPtr;
if (dlPtr == NULL) {
- TkTextIndex indexPtr2;
/*
* We're past the last display line, either because the desired
* index lies past the visible text, or because the desired index
- * is on the last display line showing the last logical line.
+ * is on the last display line.
*/
indexPtr2 = dlPtrPrev->index;
TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount,
&indexPtr2);
if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) {
+ /*
+ * The desired index is on the last display line.
+ * --> return this display line.
+ */
dlPtr = dlPtrPrev;
- break;
} else {
- return NULL;
+ /*
+ * The desired index is past the visible text. There is no
+ * display line displaying something at the desired index.
+ * --> return NULL.
+ */
}
+ break;
}
if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) {
- dlPtr = dlPtrPrev;
+ /*
+ * If we're here then we would normally expect that:
+ * dlPtrPrev->index <= indexPtr < dlPtr->index
+ * i.e. we have found the searched display line being dlPtr.
+ * However it is possible that some DLines were unlinked
+ * previously, leading to a situation where going through
+ * the list of display lines skips display lines that did
+ * exist just a moment ago.
+ */
+ indexPtr2 = dlPtrPrev->index;
+ TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount,
+ &indexPtr2);
+ if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) {
+ /*
+ * Confirmed:
+ * dlPtrPrev->index <= indexPtr < dlPtr->index
+ * --> return dlPtrPrev.
+ */
+ dlPtr = dlPtrPrev;
+ } else {
+ /*
+ * The last (rightmost) index shown by dlPtrPrev is still
+ * before the desired index. This may be because there was
+ * previously a display line between dlPtrPrev and dlPtr
+ * and this display line has been unlinked.
+ * --> return dlPtr.
+ */
+ }
break;
}
}