Issue 119400 - Undo broken in several contexts (Basic Editor, Math Editor, Calc Input Line, MultiLine controls, etc)
Summary: Undo broken in several contexts (Basic Editor, Math Editor, Calc Input Line, ...
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC All
: P3 Normal
Target Milestone: ---
Assignee: Oliver-Rainer Wittmann
QA Contact:
Keywords: regression
: 119160 (view as issue list)
Depends on:
Reported: 2012-05-22 13:11 UTC by DonJaime
Modified: 2013-02-24 21:01 UTC (History)
11 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---
jsc: 3.4.1_release_blocker+

Proposed patch to fix this problem (653 bytes, patch)
2012-05-29 12:16 UTC, hanya
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description DonJaime 2012-05-22 13:11:58 UTC
In OO 3.4.0 undoing edits in the IDE leaves a horrible mix of recent additions and deletions.

For example if you do the following:

1. create a new Macro in a new module in a new file
2. type "fruitbat"
3. select "fruitbat"
4. type "aardvark"
5. hit ctrl-Z

you will see "fruitbataardvark".

While fixing this, it would be useful to have ctrl-Y bound to 'Redo' as well.
Comment 1 bmarcelly 2012-05-23 12:29:35 UTC
Ctrl-Z works for me. 3.3.0  OOO330m20 on Windows XP
Comment 2 hanya 2012-05-23 12:42:34 UTC
I could confirm on AOO 3.4.0, Linux (Xubuntu 12.01) 32bit and Xfce 4.8. 
It works on OOo 3.3.0.
Comment 3 bmarcelly 2012-05-23 13:32:57 UTC
Sorry for my previous comment. I mixed up versions! Confirmed with 3.4.0.
Comment 4 T. J. Frazier 2012-05-23 18:56:26 UTC
Confirmed under 3.4 Beta on WV. That should narrow the search.
Comment 5 hanya 2012-05-24 15:19:23 UTC
This undo problem is not only on Basic IDE. I met the same problem on 
HTML source window and multi-line text field on basic dialog. 
It seems edit engine has such problem.
Comment 6 hanya 2012-05-25 07:11:50 UTC
Hm, input line of Calc has the same problem.

I thought the problem is there in undo action of overwrite selection but I noticed 
input events through keyboard are not tracked as undo action.

The following patch is influenced to svl, so it is widely used in the code, it should be well tested.

Index: svl/source/undo/undo.cxx
--- svl/source/undo/undo.cxx	(revision 1342285)
+++ svl/source/undo/undo.cxx	(working copy)
@@ -627,7 +627,7 @@
     // merge, if required
 	SfxUndoAction* pMergeWithAction = m_pData->pActUndoArray->nCurUndoAction ?
 		m_pData->pActUndoArray->aUndoActions[m_pData->pActUndoArray->nCurUndoAction-1].pAction : NULL;
-	if ( bTryMerge && ( !pMergeWithAction || !pMergeWithAction->Merge( pAction ) ) )
+	if ( bTryMerge && ( pMergeWithAction && pMergeWithAction->Merge( pAction ) ) )
         i_guard.markForDeletion( pAction );
         return false;
Comment 7 hanya 2012-05-25 07:30:36 UTC
I forgot to mention about the patch above, comment 6.

When I push key to input a charactor in focused text field (multi-lined), 
TextEngine::ImpInsertText method in main/svtools/source/edit/texteng.cxx is called. 
In the method, bTryMerge is true for InsertUndo( pNewUndo, bTryMerge ) call for 
first key input. 
pMergeWithAction is NULL for first input in SfxUndoManager::ImplAddUndoAction_NoNotify method. So, the action is abandoned at the if statement and not tracked.
Comment 8 hanya 2012-05-29 12:16:28 UTC
Created attachment 77735 [details]
Proposed patch to fix this problem

I met the same problem in these edit context: 
- Input line of Calc
- Multi line text field of dialogs
- Text editing in drawing object
Comment 9 hanya 2012-05-29 12:17:28 UTC
Could it be a release blocker for 3.4.1 and included in 3.4.1?
Comment 10 Ariel Constenla-Haile 2012-05-31 10:59:35 UTC
(In reply to comment #8)
> Created attachment 77735 [details]
> Proposed patch to fix this problem
> I met the same problem in these edit context: 
> - Input line of Calc
> - Multi line text field of dialogs
> - Text editing in drawing object

It also happens on Math.
Adjusting the subject to reflect this "brokenness" everywhere.
Comment 11 binguo 2012-06-13 05:19:37 UTC
This bug can repros on AOO3.4.O Rev. 1327774,
and I change the status from Unconfirmed to confirmed.
Comment 12 Oliver-Rainer Wittmann 2012-06-15 06:33:19 UTC
I am volunteering to review the proposed patch.
Comment 13 Oliver-Rainer Wittmann 2012-06-15 06:55:31 UTC
Patch looks good.
Taking over this issue for integration of the patch.

I also agree to solve this issue for AOO 3.4.1 -> I will send a corresponding request to ooo-dev
Comment 14 Oliver-Rainer Wittmann 2012-06-15 06:56:11 UTC
This is a regression in AOO 3.4 - OOo 3.3 works fine.
Comment 15 jsc 2012-06-15 07:15:21 UTC
set release blocker flag
Comment 16 Oliver-Rainer Wittmann 2012-06-15 11:37:21 UTC
commited patch on branch AOO34 - change file:
svl/source/undo/undo.cxx, revision 1350569
Comment 17 Oliver-Rainer Wittmann 2012-06-15 11:51:42 UTC
merged patch from branch AOO34 into trunk - revision 1350585
Comment 18 hanya 2012-06-15 12:06:48 UTC
Thanks for committing.
Comment 19 louqle 2012-06-18 05:47:57 UTC
verified in r1350879 against Basic IDE, spreadsheet, multi-line field of dialogs, text editing in drawing object
Comment 20 jsc 2012-06-21 12:15:32 UTC
set release blocker flag for 3.4.1
Comment 21 Terry Yang 2012-06-26 06:07:25 UTC
Verify fixed on AOO 3.4 Branch Dev snapshot rev.1351960 and AOO Trunk Rev. 1351712

Suggest close this bug
Comment 22 jsc 2012-07-25 09:20:43 UTC
set target milestone AOO 3.4.1
Comment 23 Alexander 2013-01-11 19:57:44 UTC
*** Issue 119160 has been marked as a duplicate of this issue. ***