From: SourceForge.net <no...@so...> - 2006-03-31 06:29:36
|
Bugs item #1275237, was opened at 2005-08-28 11:40 Message generated for change (Comment added) made by hobbs You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=1275237&group_id=12997 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 18. [text] Group: obsolete: 8.4.11 >Status: Closed >Resolution: Fixed Priority: 6 Submitted By: fvogelnew1 (fvogelnew1) >Assigned to: Jeffrey Hobbs (hobbs) Summary: modified flag not managed when undoing certain text inserts Initial Comment: The modified flag of the text widget is not well managed by Tk when certain changes are undone. Example 1 (works OK): text .t -undo 1 pack .t .t insert 1.0 "Hello world! " .t edit reset .t edit modified false .t insert 1.14 "Goodbye!" puts [.t edit modified] .t edit undo puts [.t edit modified] The output in the console is: 1 0 which is correct: the modified flag has been reset to false by the undo. Example 2 (wrong results): text .t -undo 1 pack .t .t insert 1.0 "Hello world! " .t edit reset .t edit modified false .t insert 1.14 "" puts [.t edit modified] .t edit undo puts [.t edit modified] The only difference is that instead of inserting "Goodbye!" the script inserts an empty string "". The output in the console is in this case: 1 1 i.e. the modified flag was not reset by the undo operation. The undo has been correctly performed since a further .t edit undo spits: nothing to undo This problem therefore concerns only the modified flag. ---------------------------------------------------------------------- >Comment By: Jeffrey Hobbs (hobbs) Date: 2006-03-30 22:29 Message: Logged In: YES user_id=72656 I have commited to 8.4.13 with a change that doesn't do anything in InsertChars is *string == '\0'. ---------------------------------------------------------------------- Comment By: fvogelnew1 (fvogelnew1) Date: 2006-03-19 11:33 Message: Logged In: YES user_id=1245417 Thanks, Any chance to have it in the upcoming 8.4.13? Francois ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2006-03-18 07:53 Message: Logged In: NO Fixed in cvs HEAD by not touching undo/modified information when inserting empty strings. ---------------------------------------------------------------------- Comment By: fvogelnew1 (fvogelnew1) Date: 2006-03-18 05:21 Message: Logged In: YES user_id=1245417 Vince, Did you try this patch or apply it to HEAD? Francois ---------------------------------------------------------------------- Comment By: Ludwig Callewaert (lgac) Date: 2005-12-28 02:41 Message: Logged In: YES user_id=316951 Patch 1391852 submitted to fix this. But as stated below, a better fix may be to bail out early if the string to be inserted is empty. ---------------------------------------------------------------------- Comment By: Ludwig Callewaert (lgac) Date: 2005-12-28 02:28 Message: Logged In: YES user_id=316951 The problem is due to an assymmetry in the insert and delete of text. When an insert is done and undo is enabled, two commands are recorded on teh undo stack: a delete command to undo the change, and an insert command to redo the change. So when undoing an insert, the recorded delete command is executed. When the insert string is empty however, there will be nothing to delete, and the delete command will prematurely exit, before setting the modified flag correctly (in fact the isDirty flag needs to be decremented). The result is that the modified flag (aka the isDirty flag) does not become zero, and the modified command still returns true although all changes have been undone. I have made a patch that fixes the problem by not recording some thing on the undo stack is the string to insert is empty. However a better fix may be to not do anything altogether when trying to insert an empty string (similar to doing nothing when both indices for a delete are identical). I was not sure however that there would be no sideeffects for this, so maybe someone can have a look at this? Vince? ---------------------------------------------------------------------- Comment By: Vince Darley (vincentdarley) Date: 2005-09-07 02:49 Message: Logged In: YES user_id=32170 'fraid I don't know much about the modified/undo stuff -- that's not been part of the changes I've been dealing with in the text widget. Particularly since this is in 8.4.x it's even further removed. (Although I would imagine the same problem is in 8.5.x). Perhaps you should see if Ludwig (TIP#26 author) can take a look. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=1275237&group_id=12997 |