summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2021-04-11 18:40:01 (GMT)
committerfvogel <fvogelnew1@free.fr>2021-04-11 18:40:01 (GMT)
commita3ea56136eebaeb8b37cd87b3b5f7c7142cd22d8 (patch)
tree81f01c93e295b4db3a429e3f47c9ad7d410b5967 /generic
parent1225fcb36c1772b3d91b8ae8f65086eb518cee25 (diff)
downloadtk-a3ea56136eebaeb8b37cd87b3b5f7c7142cd22d8.zip
tk-a3ea56136eebaeb8b37cd87b3b5f7c7142cd22d8.tar.gz
tk-a3ea56136eebaeb8b37cd87b3b5f7c7142cd22d8.tar.bz2
Backout dzach's patch, and propose a better patch that restricts the index returned by GetIndex() to -startline/-endline thresholds.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkTextIndex.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index 84bdbee..264890e 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -997,6 +997,37 @@ GetIndex(
if (indexPtr->linePtr == NULL) {
Tcl_Panic("Bad index created");
}
+
+ /*
+ * Restrict indexPtr to -startline/-endline thresholds.
+ */
+
+ if (textPtr) {
+ if (textPtr->start != NULL) {
+ int start;
+ TkTextIndex indexStart;
+
+ start = TkBTreeLinesTo(NULL, textPtr->start);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, start, 0,
+ &indexStart);
+ if (TkTextIndexCmp(indexPtr, &indexStart) < 0) {
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, start, 0,
+ indexPtr);
+ }
+ }
+ if (textPtr->end != NULL) {
+ int end;
+ TkTextIndex indexEnd;
+
+ end = TkBTreeLinesTo(NULL, textPtr->end);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, end, 0,
+ &indexEnd);
+ if (TkTextIndexCmp(indexPtr, &indexEnd) > 0) {
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, end, 0,
+ indexPtr);
+ }
+ }
+ }
return TCL_OK;
error: