summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkTextMark.c41
-rw-r--r--tests/textMark.test14
3 files changed, 51 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index c013262..7240b9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-22 Francois Vogel <fvogelnew1@free.fr>
+
+ * generic/tkTextMark.c: [Bug-3288113,3288121]: Missing marks/endless
+ * tests/textMark.test: loop in text mark prev/next
+
2012-01-19 Francois Vogel <fvogelnew1@free.fr>
* generic/tkText.c: [Bug-3021557]: Moving the cursor in
diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c
index 1c08b4a..6117127 100644
--- a/generic/tkTextMark.c
+++ b/generic/tkTextMark.c
@@ -806,11 +806,17 @@ MarkFindNext(
Tcl_SetResult(interp, "current", TCL_STATIC);
} else if (segPtr == textPtr->insertMarkPtr) {
Tcl_SetResult(interp, "insert", TCL_STATIC);
- } else if (segPtr->body.mark.textPtr != textPtr) {
+ } else if (segPtr->body.mark.hPtr == NULL) {
/*
* Ignore widget-specific marks for the other widgets.
- */
-
+ * This is either an insert or a current mark
+ * (markPtr->body.mark.hPtr actually receives NULL
+ * for these marks in TkTextSetMark).
+ * The insert and current marks for textPtr having
+ * already been tested above, the current segment is
+ * an insert or current mark from a peer of textPtr,
+ * which we don't want to return.
+ */
continue;
} else {
Tcl_SetResult(interp,
@@ -893,7 +899,7 @@ MarkFindPrev(
while (1) {
/*
* segPtr points just past the first possible candidate, or at the
- * begining of the line.
+ * beginning of the line.
*/
for (prevPtr = NULL, seg2Ptr = index.linePtr->segPtr;
@@ -901,26 +907,43 @@ MarkFindPrev(
seg2Ptr = seg2Ptr->nextPtr) {
if (seg2Ptr->typePtr == &tkTextRightMarkType ||
seg2Ptr->typePtr == &tkTextLeftMarkType) {
+ if (seg2Ptr->body.mark.hPtr == NULL) {
+ if (seg2Ptr != textPtr->currentMarkPtr &&
+ seg2Ptr != textPtr->insertMarkPtr) {
+ /*
+ * This is an insert or current mark from a
+ * peer of textPtr.
+ */
+ continue;
+ }
+ }
prevPtr = seg2Ptr;
}
}
if (prevPtr != NULL) {
if (prevPtr == textPtr->currentMarkPtr) {
Tcl_SetResult(interp, "current", TCL_STATIC);
+ return TCL_OK;
} else if (prevPtr == textPtr->insertMarkPtr) {
Tcl_SetResult(interp, "insert", TCL_STATIC);
- } else if (prevPtr->body.mark.textPtr != textPtr) {
+ return TCL_OK;
+ } else if (prevPtr->body.mark.hPtr == NULL) {
/*
* Ignore widget-specific marks for the other widgets.
- */
-
- continue;
+ * This is either an insert or a current mark
+ * (markPtr->body.mark.hPtr actually receives NULL
+ * for these marks in TkTextSetMark).
+ * The insert and current marks for textPtr having
+ * already been tested above, the current segment is
+ * an insert or current mark from a peer of textPtr,
+ * which we don't want to return.
+ */
} else {
Tcl_SetResult(interp,
Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
prevPtr->body.mark.hPtr), TCL_STATIC);
+ return TCL_OK;
}
- return TCL_OK;
}
index.linePtr = TkBTreePreviousLine(textPtr, index.linePtr);
if (index.linePtr == NULL) {
diff --git a/tests/textMark.test b/tests/textMark.test
index c83b4c8..a412574 100644
--- a/tests/textMark.test
+++ b/tests/textMark.test
@@ -18,6 +18,7 @@ update
.t debug on
wm geometry . {}
entry .t.e
+.t peer create .pt
.t insert 1.0 "Line 1
abcdefghijklm
@@ -188,6 +189,12 @@ test textMark-7.8 {MarkFindNext - no next mark} -setup {
.t mark set insert 3.0
.t mark next insert
} -result {}
+test textMark-7.9 {MarkFindNext - mark set in a text widget and retrieved from a peer} -setup {
+ .t mark unset {*}[.t mark names]
+} -body {
+ .t mark set mymark 1.0
+ set res [list [.pt mark next 1.0] [.pt mark next mymark] [.pt mark next insert]]
+} -result {mymark insert current}
test textMark-8.1 {MarkFindPrev - invalid mark name} -body {
.t mark prev bogus
@@ -239,7 +246,14 @@ test textMark-8.8 {MarkFindPrev - no previous mark} -setup {
.t mark set insert 3.0
.t mark prev current
} -result {}
+test textMark-8.9 {MarkFindPrev - mark set in a text widget and retrieved from a peer} -setup {
+ .t mark unset {*}[.t mark names]
+} -body {
+ .t mark set mymark 1.0
+ set res [list [.pt mark prev end] [.pt mark prev current] [.pt mark prev insert]]
+} -result {current insert mymark}
+destroy .pt
destroy .t
# cleanup