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

Bug 92962

Summary: index out of bounds when indent in js editor
Product: z_Archived Reporter: Amy Wu <for.work.things>
Component: Webtools.WST.JavascriptAssignee: Amy Wu <for.work.things>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Amy Wu CLA 2005-04-27 13:59:41 EDT
wtp runtime I20050422

1. create a new javascript file
2. add the following
// one comment
3. highlight the line and hit Tab
4. the following exception shows up in the log:

!ENTRY org.eclipse.wst.javascript.ui 4 4 2005-04-27 13:57:18.286
!MESSAGE Exception in notifyChanged() of LineStyleProviderForJava
!STACK 0
java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:2844)
	at org.eclipse.swt.SWT.error(SWT.java:2783)
	at org.eclipse.swt.SWT.error(SWT.java:2754)
	at org.eclipse.swt.custom.StyledText.redrawRange(StyledText.java:6097)
	at 
org.eclipse.wst.javascript.ui.internal.editor.JSLineStyleListener.redrawRegion
(JSLineStyleListener.java:548)
	at 
org.eclipse.wst.javascript.ui.internal.editor.JSLineStyleListener.documentChang
ed(JSLineStyleListener.java:179)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2
(AbstractDocument.java:714)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged
(AbstractDocument.java:677)
	at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged
(AbstractDocument.java:662)
	at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged
(AbstractDocument.java:739)
	at org.eclipse.jface.text.AbstractDocument.replace
(AbstractDocument.java:1030)
	at org.eclipse.jface.text.TextViewer.shiftRight(TextViewer.java:3875)
	at org.eclipse.jface.text.TextViewer.shift(TextViewer.java:3827)
	at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3549)
	at org.eclipse.jface.text.source.SourceViewer.doOperation
(SourceViewer.java:793)
	at org.eclipse.ui.texteditor.ShiftAction$1.run(ShiftAction.java:85)
	at org.eclipse.swt.custom.BusyIndicator.showWhile
(BusyIndicator.java:69)
	at org.eclipse.ui.texteditor.ShiftAction.run(ShiftAction.java:83)
	at 
org.eclipse.ui.texteditor.AbstractTextEditor$ActivationCodeTrigger.verifyKey
(AbstractTextEditor.java:633)
	at 
org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey
(TextViewer.java:415)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent
(StyledTextListener.java:55)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:866)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:851)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:659)
	at org.eclipse.swt.custom.StyledText.handleKeyDown
(StyledText.java:5059)
	at org.eclipse.swt.custom.StyledText$7.handleEvent
(StyledText.java:4806)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:866)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:851)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:879)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:875)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1182)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3126)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3029)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3466)
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:1549)
	at org.eclipse.swt.internal.BidiUtil.windowProc(BidiUtil.java:648)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1625)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2525)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1570)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1534)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench
(Workbench.java:306)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run
(IDEApplication.java:103)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run
(PlatformActivator.java:228)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:156)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:315)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:268)
	at org.eclipse.core.launcher.Main.run(Main.java:942)
	at org.eclipse.core.launcher.Main.main(Main.java:926)
Comment 1 Amy Wu CLA 2005-04-27 14:01:27 EDT
i get the same exception if i click somewhere on a line and perform 
Source->Shift Right
Comment 2 David Williams CLA 2005-06-15 01:24:03 EDT
Changed Version field given new release numbering.
Comment 3 Amy Wu CLA 2006-03-29 16:40:36 EST
The problem has to do with JSLineStyleListener trying to redraw a region during a document changed event.  Drawing in the text widget is suspended, meaning the document is not really updated, but JSLineStyleListener tries to go ahead and have the text widget redraw a region bigger than the text widget knows.  The fix is to just add an extra check before requesting the redraw region and if the redraw region requested is longer than the text widget knows, only redraw up to where the text widget knows.  This probably isn't the perfect fix, but I think it'll be good enough.
Comment 4 Amy Wu CLA 2006-03-29 16:44:26 EST
released for this week's ibuild
Comment 5 Amy Wu CLA 2006-06-19 17:30:28 EDT
verified in wtp 1.5 rc5