diff options
author | jan.nijtmans <jan.nijtmans@noemail.net> | 2012-01-19 20:33:10 (GMT) |
---|---|---|
committer | jan.nijtmans <jan.nijtmans@noemail.net> | 2012-01-19 20:33:10 (GMT) |
commit | b276d173ceaa1cc25ef288a9b621718efc09eb09 (patch) | |
tree | 9608bd5c7931602c580d2aae708a8661194c24b3 /generic | |
parent | 129869af8d3b8ad431ac46f1ba3c420ce28b90ea (diff) | |
download | tk-b276d173ceaa1cc25ef288a9b621718efc09eb09.zip tk-b276d173ceaa1cc25ef288a9b621718efc09eb09.tar.gz tk-b276d173ceaa1cc25ef288a9b621718efc09eb09.tar.bz2 |
[Bug-3288113,3288121]: Missing marks/endless loop in text mark prev/next
FossilOrigin-Name: 8ffcb51530f893fd78cd6c38433b3cb6a7168415
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkTextMark.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c index 281baf1..55edb46 100644 --- a/generic/tkTextMark.c +++ b/generic/tkTextMark.c @@ -781,11 +781,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, @@ -868,7 +874,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; @@ -876,26 +882,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) { |