Bug 93901 - Applying patch with one line added inserts new line one line above
Summary: Applying patch with one line added inserts new line one line above
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.0.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Platform-Compare-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-06 09:04 EDT by Martin Burger CLA
Modified: 2005-05-09 14:52 EDT (History)
1 user (show)

See Also:


Attachments
Possible fix (352 bytes, patch)
2005-05-06 09:10 EDT, Martin Burger CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Burger CLA 2005-05-06 09:04:50 EDT
Create a file "test.txt" with following content:

----- cut here -----
[1] Lorem
[2] ipsum
[3] dolor
[4] sit
[5] amet,
[6] consectetuer
[7] adipiscing
[8] elit.
[9] Nulla
[10] dignissim.
----- cut here -----

Apply follwing patch:

----- cut here -----
--- test.txt   Fri May  6 01:46:07 2005
+++ test.txt   Fri May  6 14:54:19 2005
@@ -5,0 +6 @@
+[5a] Lorem Ipsu. ADDED AFTER ROW [5]
----- cut here -----

The new line will be insertet before row 5:

[1] Lorem
[2] ipsum
[3] dolor
[4] sit
[5a] Lorem Ipsu. ADDED AFTER ROW [5]
[5] amet,
[6] consectetuer
[7] adipiscing
[8] elit.
[9] Nulla
[10] dignissim.

Additionally, there will be an "Unhandled event loop exception":

!ENTRY org.eclipse.ui 4 0 Mai 06, 2005 15:00:00.15
!MESSAGE Index: 4, Size: 0
!STACK 0
java.lang.IndexOutOfBoundsException: Index: 4, Size: 0
	at java.util.ArrayList.add(Unknown Source)
	at org.eclipse.compare.internal.patch.Patcher.doPatch(Patcher.java:731)
	at org.eclipse.compare.internal.patch.Patcher.patch(Patcher.java:619)
	at org.eclipse.compare.internal.patch.Patcher.patch(Patcher.java:606)
	at org.eclipse.compare.internal.patch.Patcher.apply(Patcher.java:893)
	at
org.eclipse.compare.internal.patch.PreviewPatchPage.updateTree(PreviewPatchPage.java:597)
	at
org.eclipse.compare.internal.patch.PreviewPatchPage.buildTree(PreviewPatchPage.java:516)
	at
org.eclipse.compare.internal.patch.PreviewPatchPage.setVisible(PreviewPatchPage.java:133)
	at org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:937)
	at org.eclipse.jface.wizard.WizardDialog.access$2(WizardDialog.java:920)
	at org.eclipse.jface.wizard.WizardDialog$4.run(WizardDialog.java:911)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:909)
	at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:680)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:300)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:506)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2773)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2432)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:668)
	at org.eclipse.jface.window.Window.open(Window.java:648)
	at
org.eclipse.compare.internal.patch.CompareWithPatchAction.run(CompareWithPatchAction.java:65)
	at org.eclipse.compare.internal.BaseCompareAction.run(BaseCompareAction.java:26)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:276)
	at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:915)
	at
org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:866)
	at
org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:785)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2773)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2432)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
	at org.eclipse.core.launcher.Main.run(Main.java:704)
	at org.eclipse.core.launcher.Main.main(Main.java:688)
Comment 1 Martin Burger CLA 2005-05-06 09:10:47 EDT
Created attachment 20772 [details]
Possible fix

The patch fixes this issue partly. Line is added at correct row, but
furthermore exception is thrown.
Comment 2 Andre Weinand CLA 2005-05-06 13:13:28 EDT
The reason for the IndexOutOfBoundsException is probably a missing tab separator in 
the header:
--- test.txt   Fri May  6 01:46:07 2005
+++ test.txt   Fri May  6 14:54:19 2005

the tab should between the "test.txt" and the "Fri...".

Without the tab the whole line "test.txt   Fri May  6 01:46:07 2005" is considered the file to patch.
Comment 3 Andre Weinand CLA 2005-05-06 18:56:57 EDT
Patch applied;
IndexOutOfBoundsException fixed;
added 3 new test cases