diff options
author | dkf <dkf@noemail.net> | 2007-12-11 22:14:56 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2007-12-11 22:14:56 (GMT) |
commit | 99e332be876da8b0aae2385bdc40165d24de7da7 (patch) | |
tree | 3918f2317b3bfcb7ac116ac2192f574b7c3d97b6 /generic | |
parent | ecbd8ef25d3f8aaaccc74b3f5eec6d557babd579 (diff) | |
download | tk-99e332be876da8b0aae2385bdc40165d24de7da7.zip tk-99e332be876da8b0aae2385bdc40165d24de7da7.tar.gz tk-99e332be876da8b0aae2385bdc40165d24de7da7.tar.bz2 |
Added code to rebuild the from index after the deletion phase so that the
linePtr field is valid for the insertion phase. [Bug 1602537]
FossilOrigin-Name: 44205e71b2aa75beb41ed9c1d1ba65752eda3bd5
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkText.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/generic/tkText.c b/generic/tkText.c index 5c18277..ac40ac5 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.76 2007/09/07 00:34:54 dgp Exp $ + * RCS: @(#) $Id: tkText.c,v 1.77 2007/12/11 22:14:58 dkf Exp $ */ #include "default.h" @@ -1726,7 +1726,8 @@ TextReplaceCmd( */ int origAutoSep = textPtr->sharedTextPtr->autoSeparators; - int result; + int result, lineNumber; + TkTextIndex indexTmp; if (textPtr->sharedTextPtr->undo) { textPtr->sharedTextPtr->autoSeparators = 0; @@ -1736,9 +1737,18 @@ TextReplaceCmd( } } + /* + * Must save and restore line in indexFromPtr based on line number; can't + * keep the line itself as that might be eliminated/invalidated when + * deleting the range. [Bug 1602537] + */ + + indexTmp = *indexFromPtr; + lineNumber = TkBTreeLinesTo(textPtr, indexFromPtr->linePtr); DeleteIndexRange(NULL, textPtr, indexFromPtr, indexToPtr, viewUpdate); + indexTmp.linePtr = TkBTreeFindLine(indexTmp.tree, textPtr, lineNumber); result = TextInsertCmd(NULL, textPtr, interp, objc-4, objv+4, - indexFromPtr, viewUpdate); + &indexTmp, viewUpdate); if (textPtr->sharedTextPtr->undo) { textPtr->sharedTextPtr->lastEditMode = TK_TEXT_EDIT_REPLACE; @@ -3101,7 +3111,7 @@ DeleteIndexRange( Tcl_Obj *get; if (sharedTextPtr->autoSeparators - && (sharedTextPtr->lastEditMode != TK_TEXT_EDIT_DELETE)) { + && (sharedTextPtr->lastEditMode != TK_TEXT_EDIT_DELETE)) { TkUndoInsertUndoSeparator(sharedTextPtr->undoStack); } @@ -3123,17 +3133,18 @@ DeleteIndexRange( if (line != -1) { int byteIndex = lineAndByteIndex[resetViewCount+1]; + TkTextIndex indexTmp; if (tPtr == textPtr) { if (viewUpdate) { TkTextMakeByteIndex(sharedTextPtr->tree, textPtr, line, - byteIndex, &index1); - TkTextSetYView(tPtr, &index1, 0); + byteIndex, &indexTmp); + TkTextSetYView(tPtr, &indexTmp, 0); } } else { - TkTextMakeByteIndex(sharedTextPtr->tree, NULL, line, byteIndex, - &index1); - TkTextSetYView(tPtr, &index1, 0); + TkTextMakeByteIndex(sharedTextPtr->tree, NULL, line, + byteIndex, &indexTmp); + TkTextSetYView(tPtr, &indexTmp, 0); } } resetViewCount += 2; @@ -3143,7 +3154,6 @@ DeleteIndexRange( } if (line1 >= line2) { - /* * Invalidate any selection retrievals in progress, assuming we didn't * check for this case above. |