From 9cd09caa8af69a036f42dffe2a31f129a881bdb8 Mon Sep 17 00:00:00 2001 From: vincentdarley Date: Sat, 18 Mar 2006 15:52:12 +0000 Subject: undo/modified and empty string fix --- ChangeLog | 5 +++++ generic/tkText.c | 32 ++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index d30a688..b20829a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-03-18 Vince Darley + + * generic/tkText.c: fix for undo/modified status of text + widgets when empty strings are inserted and undone. + 2006-03-17 Pat Thoyts * library/clrpick.tcl: bug #1451587: avoid using abbreviated diff --git a/generic/tkText.c b/generic/tkText.c index f99ce02..7b8586f 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.64 2005/11/27 02:36:14 das Exp $ + * RCS: @(#) $Id: tkText.c,v 1.65 2006/03/18 15:52:32 vincentdarley Exp $ */ #include "default.h" @@ -2548,24 +2548,28 @@ InsertChars(sharedTextPtr, textPtr, indexPtr, stringPtr, viewUpdate) TkBTreeInsertChars(sharedTextPtr->tree, indexPtr, string); /* - * Push the insertion on the undo stack + * Push the insertion on the undo stack, and update + * the modified status of the widget */ - if (sharedTextPtr->undo) { - TkTextIndex toIndex; - - if (sharedTextPtr->autoSeparators && - sharedTextPtr->lastEditMode != TK_TEXT_EDIT_INSERT) { - TkUndoInsertUndoSeparator(sharedTextPtr->undoStack); + if (length > 0) { + if (sharedTextPtr->undo) { + TkTextIndex toIndex; + + if (sharedTextPtr->autoSeparators && + sharedTextPtr->lastEditMode != TK_TEXT_EDIT_INSERT) { + TkUndoInsertUndoSeparator(sharedTextPtr->undoStack); + } + + sharedTextPtr->lastEditMode = TK_TEXT_EDIT_INSERT; + + TkTextIndexForwBytes(textPtr, indexPtr, length, &toIndex); + TextPushUndoAction(textPtr, stringPtr, 1, indexPtr, &toIndex); } - sharedTextPtr->lastEditMode = TK_TEXT_EDIT_INSERT; - - TkTextIndexForwBytes(textPtr, indexPtr, length, &toIndex); - TextPushUndoAction(textPtr, stringPtr, 1, indexPtr, &toIndex); + UpdateDirtyFlag(sharedTextPtr); } - - UpdateDirtyFlag(sharedTextPtr); + resetViewCount = 0; for (tPtr = sharedTextPtr->peers; tPtr != NULL ; tPtr = tPtr->next) { -- cgit v0.12