Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339714 - [linked mode] Pressing undo during rename refactoring fails and reverts all recent changes
Summary: [linked mode] Pressing undo during rename refactoring fails and reverts all r...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-11 11:25 EST by Tobias Oberlies CLA
Modified: 2019-11-14 03:28 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Oberlies CLA 2011-03-11 11:25:49 EST
I know that I could have done this differently - and I agree that this does not need to work - but trying the following steps should not lead to data loss:

Initial situation:
a) I have changes in the undo history of a class
b) The following code exists in the class
private void abc()
{
    String newname = "a";
    oldname += "bc";
    System.out.println(oldname);
    // more uses of oldname
}

Steps to reproduce:
1) Copy "oldname", select "newname", hit CTRL+V
2) CTRL+SHIFT+R -> linked edit of all occurrences of "oldname"
3) CTRL+Z -> only variable declaration changes to "newname", other occurrences of "oldname" are unchanged
4) ENTER -> an error dialog appears (which is kind of expected)
5) Confirm the dialog
And this is the bug: All recend changes are undone, i.e. including everything I did before step 1!

I realized later that I could have recovered my changes through Redo, but at that point I was so confused that I eventually typed something and lost my changes.
Comment 1 Markus Keller CLA 2011-05-11 13:50:48 EDT
This is a problem in the Linked Mode implementation. The Undo is not propagated to the other linked positions because AbstractDocument#fAcceptPostNotificationReplaces is false and thus the other changes are dropped at the location shown below.

See also bug 77575.


Thread [main] (Suspended)	
	owns: Object  (id=13951)	
	SynchronizableDocument(AbstractDocument).registerPostNotificationReplace(IDocumentListener, IDocumentExtension$IReplace) line: 1340	
	LinkedModeModel$DocumentListener.documentChanged(DocumentEvent) line: 238	
	SynchronizableDocument(AbstractDocument).doFireDocumentChanged2(DocumentEvent) line: 769	
	SynchronizableDocument(AbstractDocument).doFireDocumentChanged(DocumentEvent, boolean, IRegion) line: 736	
	SynchronizableDocument(AbstractDocument).doFireDocumentChanged(DocumentEvent) line: 721	
	SynchronizableDocument(AbstractDocument).fireDocumentChanged(DocumentEvent) line: 796	
	SynchronizableDocument(AbstractDocument).replace(int, int, String, long) line: 1191	
	SynchronizableDocument.replace(int, int, String, long) line: 194	
	DocumentUndoManager$UndoableTextChange.undoTextChange() line: 144	
	DocumentUndoManager$UndoableTextChange.undo(IProgressMonitor, IAdaptable) line: 264	
	DefaultOperationHistory.doUndo(IProgressMonitor, IAdaptable, IUndoableOperation) line: 417	
	DefaultOperationHistory.undo(IUndoContext, IProgressMonitor, IAdaptable) line: 1282	
	UndoActionHandler.runCommand(IProgressMonitor) line: 78	
	OperationHistoryActionHandler$4.run(IProgressMonitor) line: 311	
	ModalContext.runInCurrentThread(IRunnableWithProgress, IProgressMonitor) line: 464	
	ModalContext.run(IRunnableWithProgress, boolean, IProgressMonitor, Display) line: 372	
	TimeTriggeredProgressMonitorDialog(ProgressMonitorDialog).run(boolean, boolean, IRunnableWithProgress) line: 507	
	TimeTriggeredProgressMonitorDialog.access$6(TimeTriggeredProgressMonitorDialog, boolean, boolean, IRunnableWithProgress) line: 1	
	TimeTriggeredProgressMonitorDialog$2.run() line: 203	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	TimeTriggeredProgressMonitorDialog.run(boolean, boolean, IRunnableWithProgress) line: 216	
	UndoActionHandler(OperationHistoryActionHandler).run() line: 326	
	UndoActionHandler(Action).runWithEvent(Event) line: 498	
	ActionHandler.execute(Map) line: 185	
	LegacyHandlerWrapper.execute(ExecutionEvent) line: 109	
	Command.executeWithChecks(ExecutionEvent) line: 476	
	ParameterizedCommand.executeWithChecks(Object, Object) line: 508	
	HandlerService.executeCommand(ParameterizedCommand, Event) line: 169	
	WorkbenchKeyboard.executeCommand(Binding, Event) line: 468	
	WorkbenchKeyboard.press(List, Event) line: 786	
	WorkbenchKeyboard.processKeyEvent(List, Event) line: 885	
	WorkbenchKeyboard.filterKeySequenceBindings(Event) line: 567	
	WorkbenchKeyboard.access$3(WorkbenchKeyboard, Event) line: 508	
	WorkbenchKeyboard$KeyDownFilter.handleEvent(Event) line: 123	
	EventTable.sendEvent(Event) line: 89	
	Display.filterEvent(Event) line: 1262	
	StyledText(Widget).sendEvent(Event) line: 1061	
	StyledText(Widget).sendEvent(int, Event, boolean) line: 1086	
	StyledText(Widget).sendEvent(int, Event) line: 1071	
	StyledText(Widget).sendKeyEvent(int, int, int, int, Event) line: 1113	
	StyledText(Widget).sendKeyEvent(int, int, int, int) line: 1109	
	StyledText(Widget).wmChar(int, int, int) line: 1518	
	StyledText(Control).WM_CHAR(int, int) line: 4623	
	StyledText(Canvas).WM_CHAR(int, int) line: 345	
	StyledText(Control).windowProc(int, int, int, int) line: 4511	
	StyledText(Canvas).windowProc(int, int, int, int) line: 341	
	Display.windowProc(int, int, int, int) line: 4970	
	OS.$$YJP$$CallWindowProcW(int, int, int, int, int) line: not available [native method]	
	OS.CallWindowProcW(int, int, int, int, int) line: not available	
	OS.CallWindowProc(int, int, int, int, int) line: 2420	
	BidiUtil.windowProc(int, int, int, int) line: 639	
	OS.$$YJP$$DispatchMessageW(MSG) line: not available [native method]	
	OS.DispatchMessageW(MSG) line: not available	
	OS.DispatchMessage(MSG) line: 2526	
	Display.readAndDispatch() line: 3750
Comment 2 Dani Megert CLA 2011-11-15 05:28:49 EST
Deepak, please investigate.
Comment 3 Dani Megert CLA 2012-05-09 08:53:54 EDT
> See also bug 77575.
This one is not directly related. The bug got introduced during 3.5 and most likely not by a change in linked mode but by a fix for the rename refactoring.
Comment 4 Lars Vogel CLA 2019-11-14 03:28:49 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.