Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 170877

Summary: Editor viewport not correct after restart
Product: [Eclipse Project] Platform Reporter: Benno Baumgartner <benno.baumgartner>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, snorthov
Version: 3.3   
Target Milestone: 3.3 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 168524    
Bug Blocks:    
Attachments:
Description Flags
screen shot
none
Picture showing wrong horizontal thumb none

Description Benno Baumgartner CLA 2007-01-18 03:59:39 EST
I20070109-1805

1. Open org.eclipse.jdt.internal.ui.text.spelling.SpellingEngine
2. Restart eclipse
Is:
 The vertical scrollbar of the editor is all to the left but the editor does not show first column of content... see screenshot

Can reproduce. One click on the vertical scrollbar does recenter the editor content correctly.
Comment 1 Benno Baumgartner CLA 2007-01-18 04:00:33 EST
Created attachment 57067 [details]
screen shot
Comment 2 Dani Megert CLA 2007-01-22 05:43:31 EST
Can reproduce (also with normal text editor). This looks like the same problem as we had with the vertical positioning (see bug 168429).

Moving to SWT for comments.
Comment 3 Dani Megert CLA 2007-01-22 05:45:35 EST
Created attachment 57243 [details]
Picture showing wrong horizontal thumb
Comment 4 Dani Megert CLA 2007-02-06 10:15:30 EST
This can confuse users. A fix for M5 would be great.
Comment 5 Steve Northover CLA 2007-02-06 10:26:12 EST
Felipe, it is our problem?
Comment 6 Dani Megert CLA 2007-02-06 10:40:48 EST
Note that it sometimes works. It depends where the caret is but I could not yet figure out the pattern.
Comment 7 Dani Megert CLA 2007-02-06 11:04:37 EST
Two things I observe which might help to track this down:
1. it seems to happen when the selection is at a position that normally doesn't
   require to scroll in order to see it.

2. only the very first editor restored by the platform is affected. The reason why it doesn't work for the very first one is captured in bug 168524. This might give you a hint.
Comment 8 Felipe Heidrich CLA 2007-02-06 12:32:38 EST
Daniel, I fixed StyledText to honour setHorizontalOffset (the thumb of the
scrollbar is correct). However the text is still scroll to the right because
you are calling the API.
Comment 9 Felipe Heidrich CLA 2007-02-06 12:33:24 EST
fixed in HEAD > 20070206
Comment 10 Dani Megert CLA 2007-02-06 13:02:21 EST
I'll have to check why we call it in this scenario. Probably because the widget isn't fully visible yet and hence we use wrong numbers to compute the index.
Comment 11 Dani Megert CLA 2007-02-06 13:26:09 EST
Can you release this into the map file for I20070207-0010 so that I can test this tomorrow along with the other SWT contributions that aren't in I20070206-0010?
Comment 12 Felipe Heidrich CLA 2007-02-06 14:58:51 EST
(In reply to comment #11)
> Can you release this into the map file for I20070207-0010 so that I can test
> this tomorrow along with the other SWT contributions that aren't in
> I20070206-0010?

you got it.
Comment 13 Dani Megert CLA 2007-02-07 06:09:11 EST
The problem is that fTextWidget.getClientArea().width returns 0 and hence my computation is wrong and assumes it needs to call setHorizontalIndex(int).

Is there any way (besides Platform UI fixing bug 168524) that StyledText can return the "correct" width in this scenario?
Comment 14 Steve Northover CLA 2007-02-07 07:39:44 EST
What are the bounds of the control when you ask for the client area?
Comment 15 Dani Megert CLA 2007-02-07 08:04:18 EST
Rectangle {29, 0, 0, 0}
Comment 16 Steve Northover CLA 2007-02-07 10:46:53 EST
The width and height are zero.  How can the client area be anything else?
Comment 17 Dani Megert CLA 2007-02-07 10:49:19 EST
I guess there's nothing that SWT or Text can do than wait for the Platform to make sure the part is indeed activated when they send partActivated.
Comment 18 Steve Northover CLA 2007-02-07 10:54:13 EST
This is the old classic bug/feature that every text control on every operating system has had since the beginning of time.  Is goes like this:

0) The text control is created (size is zero)
1) The text control state is configured
    - the selection or the left index is set
    - this causes the control to scroll horizontally
2) The text control is resized
    - if this were done first, the scrolling in 1) would not be necessary
    - the text control can't know to undo the scrolling
    - it could have been the user and the scrolling should not change

We can help you fix this and/or work around it.  Where is the code?
Comment 19 Dani Megert CLA 2007-02-07 11:35:45 EST
I think the code that is responsible is the one in the workbench that does the intial startup and causes its components to be layouted before the window has a size i.e. all controls in a view or editor are affected by this.

Here is where the 0-bounds are set:

Thread [main] (Suspended (breakpoint at line 2312 in Control))	
	owns: RunnableLock  (id=444)	
	StyledText(Control).setBounds(int, int, int, int, int) line: 2312	
	StyledText(Control).setBounds(int, int, int, int) line: 2308	
	SourceViewer$RulerLayout.layout(Composite, boolean) line: 136	
	Canvas(Composite).updateLayout(boolean, boolean) line: 987	
	Canvas(Composite).layout(boolean, boolean) line: 531	
	Canvas(Composite).layout(boolean) line: 496	
	CompositeRuler.layoutTextViewer() line: 609	
	CompositeRuler.addDecorator(int, IVerticalRulerColumn) line: 563	
	AbstractTextEditor$11.run() line: 1572	
	SafeRunner.run(ISafeRunnable) line: 37	
	AbstractDecoratedTextEditor$1(AbstractTextEditor$ColumnSupport).addColumn(CompositeRuler, RulerColumnDescriptor) line: 1575	
	AbstractDecoratedTextEditor$1(AbstractTextEditor$ColumnSupport).setColumnVisible(RulerColumnDescriptor, boolean) line: 1559	
	TextEditor(AbstractTextEditor).updateContributedRulerColumns(CompositeRuler) line: 2758	
	TextEditor(AbstractTextEditor).createPartControl(Composite) line: 3028	
	TextEditor(StatusTextEditor).createPartControl(Composite) line: 53	
	TextEditor(AbstractDecoratedTextEditor).createPartControl(Composite) line: 373	
	EditorReference.createPartHelper() line: 662	
	EditorReference.createPart() line: 421	
	EditorReference(WorkbenchPartReference).getPart(boolean) line: 586	
	EditorAreaHelper.setVisibleEditor(IEditorReference, boolean) line: 263	
	EditorManager.setVisibleEditor(IEditorReference, boolean) line: 1510	
	EditorManager$5.runWithException() line: 1044	
	EditorManager$5(StartupThreading$StartupRunnable).run() line: 31	
	RunnableLock.run() line: 35	
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 123	
	Display.runAsyncMessages(boolean) line: 3467	
	Display.readAndDispatch() line: 3107	
	Workbench.runUI() line: 2187	
	Workbench.access$4(Workbench) line: 2103	
	Workbench$4.run() line: 457	
	Realm.runWithDefault(Realm, Runnable) line: 289	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 452	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 101	
	EclipseAppHandle.run(Object) line: 146	
	EclipseAppLauncher.runApplication(Object) line: 106	
	EclipseAppLauncher.start(Object) line: 76	
	EclipseStarter.run(Object) line: 354	
	EclipseStarter.run(String[], Runnable) line: 169	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 585	
	Main.invokeFramework(String[], URL[]) line: 476	
	Main.basicRun(String[]) line: 416	
	Main.run(String[]) line: 1124	
	Main.main(String[]) line: 1099	



Here is where the correct bounds are set (too late):
Thread [main] (Suspended (breakpoint at line 2312 in Control))	
	owns: RunnableLock  (id=757)	
	StyledText(Control).setBounds(int, int, int, int, int) line: 2312	
	StyledText(Control).setBounds(int, int, int, int) line: 2308	
	SourceViewer$RulerLayout.layout(Composite, boolean) line: 136	
	Canvas(Composite).updateLayout(boolean, boolean) line: 987	
	Canvas(Composite).WM_SIZE(int, int) line: 1279	
	Canvas.WM_SIZE(int, int) line: 303	
	Canvas(Control).windowProc(int, int, int, int) line: 3545	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]	
	OS.DefWindowProc(int, int, int, int) line: 2195	
	Canvas(Scrollable).callWindowProc(int, int, int, int) line: 77	
	Canvas(Control).windowProc(int, int, int, int) line: 3562	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.SetWindowPos(int, int, int, int, int, int, int) line: not available [native method]	
	Canvas(Widget).SetWindowPos(int, int, int, int, int, int, int) line: 1235	
	Canvas(Control).setBounds(int, int, int, int, int, boolean) line: 2330	
	Canvas(Control).setBounds(int, int, int, int, int) line: 2312	
	Canvas(Control).setBounds(int, int, int, int) line: 2308	
	FillLayout.layout(Composite, boolean) line: 198	
	Composite.updateLayout(boolean, boolean) line: 987	
	Composite.WM_SIZE(int, int) line: 1279	
	Composite(Control).windowProc(int, int, int, int) line: 3545	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]	
	OS.DefWindowProc(int, int, int, int) line: 2195	
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77	
	Composite(Control).windowProc(int, int, int, int) line: 3562	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.SetWindowPos(int, int, int, int, int, int, int) line: not available [native method]	
	Composite(Widget).SetWindowPos(int, int, int, int, int, int, int) line: 1235	
	Composite(Control).setBounds(int, int, int, int, int, boolean) line: 2330	
	Composite(Control).setBounds(int, int, int, int, int) line: 2312	
	Composite(Control).setBounds(int, int, int, int) line: 2308	
	Composite(Control).setBounds(Rectangle) line: 2377	
	StackLayout.layout(Composite, boolean) line: 116	
	Composite.updateLayout(boolean, boolean) line: 987	
	Composite.WM_SIZE(int, int) line: 1279	
	Composite(Control).windowProc(int, int, int, int) line: 3545	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]	
	OS.DefWindowProc(int, int, int, int) line: 2195	
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77	
	Composite(Control).windowProc(int, int, int, int) line: 3562	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.SetWindowPos(int, int, int, int, int, int, int) line: not available [native method]	
	Composite(Widget).SetWindowPos(int, int, int, int, int, int, int) line: 1235	
	Composite(Control).setBounds(int, int, int, int, int, boolean) line: 2330	
	Composite(Control).setBounds(int, int, int, int, int) line: 2312	
	Composite(Control).setBounds(int, int, int, int) line: 2308	
	FillLayout.layout(Composite, boolean) line: 198	
	Composite.updateLayout(boolean, boolean) line: 987	
	Composite.WM_SIZE(int, int) line: 1279	
	Composite(Control).windowProc(int, int, int, int) line: 3545	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]	
	OS.DefWindowProc(int, int, int, int) line: 2195	
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77	
	Composite(Control).windowProc(int, int, int, int) line: 3562	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.SetWindowPos(int, int, int, int, int, int, int) line: not available [native method]	
	Composite(Widget).SetWindowPos(int, int, int, int, int, int, int) line: 1235	
	Composite(Control).setBounds(int, int, int, int, int, boolean) line: 2330	
	Composite(Control).setBounds(int, int, int, int, int) line: 2312	
	Composite(Control).setBounds(int, int, int, int) line: 2308	
	FillLayout.layout(Composite, boolean) line: 198	
	Composite.updateLayout(boolean, boolean) line: 987	
	Composite.WM_SIZE(int, int) line: 1279	
	Composite(Control).windowProc(int, int, int, int) line: 3545	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]	
	OS.DefWindowProc(int, int, int, int) line: 2195	
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77	
	Composite(Control).windowProc(int, int, int, int) line: 3562	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.EndDeferWindowPos(int) line: not available [native method]	
	Composite.resizeChildren(boolean, WINDOWPOS[]) line: 703	
	Composite.resizeChildren() line: 669	
	Composite.setResizeChildren(boolean) line: 875	
	Composite.WM_SIZE(int, int) line: 1283	
	Composite(Control).windowProc(int, int, int, int) line: 3545	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]	
	OS.DefWindowProc(int, int, int, int) line: 2195	
	Composite(Scrollable).callWindowProc(int, int, int, int) line: 77	
	Composite(Control).windowProc(int, int, int, int) line: 3562	
	Display.windowProc(int, int, int, int) line: 4159	
	OS.SetWindowPos(int, int, int, int, int, int, int) line: not available [native method]	
	Composite(Widget).SetWindowPos(int, int, int, int, int, int, int) line: 1235	
	Composite(Control).setBounds(int, int, int, int, int, boolean) line: 2330	
	Composite(Control).setBounds(int, int, int, int, int) line: 2312	
	Composite(Control).setBounds(int, int, int, int) line: 2308	
	Composite(Control).setBounds(Rectangle) line: 2377	
	EditorSashContainer(PartSashContainer).setBounds(Rectangle) line: 855	
	LayoutTree.doSetBounds(Rectangle) line: 547	
	LayoutTree.setBounds(Rectangle) line: 538	
	LayoutTreeNode.doSetBounds(Rectangle) line: 534	
	LayoutTreeNode(LayoutTree).setBounds(Rectangle) line: 538	
	LayoutTreeNode.doSetBounds(Rectangle) line: 503	
	LayoutTreeNode(LayoutTree).setBounds(Rectangle) line: 538	
	LayoutTreeNode.doSetBounds(Rectangle) line: 535	
	LayoutTreeNode(LayoutTree).setBounds(Rectangle) line: 538	
	LayoutTreeNode.doSetBounds(Rectangle) line: 503	
	LayoutTreeNode(LayoutTree).setBounds(Rectangle) line: 538	
	ViewSashContainer(PartSashContainer).resizeSashes() line: 814	
	ViewSashContainer(PartSashContainer).setActive(boolean) line: 532	
	PerspectiveHelper.activate(Composite) line: 248	
	Perspective.onActivate() line: 841	
	WorkbenchPage.onActivate() line: 2421	
	WorkbenchWindow$20.run() line: 2717	
	BusyIndicator.showWhile(Display, Runnable) line: 67	
	WorkbenchWindow.setActivePage(IWorkbenchPage) line: 2698	
	WorkbenchWindow$15.runWithException() line: 2053	
	WorkbenchWindow$15(StartupThreading$StartupRunnable).run() line: 31	
	RunnableLock.run() line: 35	
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 123	
	Display.runAsyncMessages(boolean) line: 3467	
	Display.readAndDispatch() line: 3107	
	Workbench.runUI() line: 2187	
	Workbench.access$4(Workbench) line: 2103	
	Workbench$4.run() line: 457	
	Realm.runWithDefault(Realm, Runnable) line: 289	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 452	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 101	
	EclipseAppHandle.run(Object) line: 146	
	EclipseAppLauncher.runApplication(Object) line: 106	
	EclipseAppLauncher.start(Object) line: 76	
	EclipseStarter.run(Object) line: 354	
	EclipseStarter.run(String[], Runnable) line: 169	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 585	
	Main.invokeFramework(String[], URL[]) line: 476	
	Main.basicRun(String[]) line: 416	
	Main.run(String[]) line: 1124	
	Main.main(String[]) line: 1099	
Comment 20 Dani Megert CLA 2007-02-07 11:36:55 EST
I think an easier "fix" for the platform would be to ensure that they do not send out partActivated until the part is realized (bug 168524).
Comment 21 Dani Megert CLA 2007-02-08 09:37:25 EST
Steve I think for book keeping we should reopen this bug, give it to Platform UI and mark it as dup of bug 168524.
Comment 22 Steve Northover CLA 2007-02-08 16:13:50 EST
Go ahead.
Comment 23 Dani Megert CLA 2007-02-08 16:16:37 EST
.
Comment 24 Dani Megert CLA 2007-02-08 16:17:40 EST
Platform Text has released a workaround for M5.

*** This bug has been marked as a duplicate of bug 168524 ***
Comment 25 Dani Megert CLA 2008-04-18 04:38:44 EDT
>Platform Text has released a workaround for M5.
Removed workaround as bug 168524 is now fixed.
Available in builds > N20080417-2000.