Bug 263458 - Enter key is ignored
Summary: Enter key is ignored
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.0.5   Edit
Assignee: Chris Jaun CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2009-02-03 09:24 EST by Michael Schneider CLA
Modified: 2010-03-03 11:13 EST (History)
1 user (show)

See Also:
thatnitind: review+


Attachments
Adds a try/catch statement to catch an exception in the JavaAutoIndentStrategy (2.29 KB, patch)
2009-03-11 17:07 EDT, Chris Jaun CLA
thatnitind: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schneider CLA 2009-02-03 09:24:32 EST
Eclipse Build ID: I20090129-1800
WTP Build ID: 3.1M4-20081219210304

to reproduce:
1) create a JS file with the following content
(function() {
	return {
		v: function() {
			A.a(dojo.hitch(this, function() {
				var v1= B.b(dojo.hitch(this, function() {}));
			}), C.c());
		}
	};
);

})();
2) try hitting enter at the end of line 1 - 3
observe: the keystroke is ignored
Comment 1 Michael Schneider CLA 2009-02-03 11:42:40 EST
raising severity as this is a major annoyance. I can't type a line break after almost every opening curly brace I've typed!
Comment 2 Chris Jaun CLA 2009-03-11 17:07:51 EDT
Created attachment 128457 [details]
Adds a try/catch statement to catch an exception in the JavaAutoIndentStrategy
Comment 3 Chris Jaun CLA 2009-03-11 17:11:17 EDT
This is happening due to an IllegalArgumentException in the JavaAutoIndentStrategy class.

It looks like the parser was having trouble with the syntax in the sample JS code and was creating objects with an illegal source end position.

java.lang.IllegalArgumentException
	at org.eclipse.wst.jsdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2537)
	at org.eclipse.wst.jsdt.core.dom.ASTConverter.convertToVariableDeclarationStatement(ASTConverter.java:2968)
	at org.eclipse.wst.jsdt.core.dom.ASTConverter.checkAndAddMultipleLocalDeclaration(ASTConverter.java:321)
	at org.eclipse.wst.jsdt.core.dom.ASTConverter.convert(ASTConverter.java:443)
	at org.eclipse.wst.jsdt.core.dom.ASTConverter.convert(ASTConverter.java:1237)
	at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.convert(JavaScriptUnitResolver.java:262)
	at org.eclipse.wst.jsdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:887)
	at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:647)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy.isClosed(JavaAutoIndentStrategy.java:516)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy.smartIndentAfterNewLine(JavaAutoIndentStrategy.java:303)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy.customizeDocumentCommand(JavaAutoIndentStrategy.java:1211)
	at org.eclipse.jface.text.TextViewer.customizeDocumentCommand(TextViewer.java:3623)
	at org.eclipse.jface.text.TextViewer.handleVerifyEvent(TextViewer.java:3645)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.handleVerifyEvent(ProjectionViewer.java:1269)
	at org.eclipse.jface.text.TextViewer$TextVerifyListener.verifyText(TextViewer.java:426)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:770)
	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:6444)
	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:7263)
	at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2425)
	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5670)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5695)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5398)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)


This fix doesn't directly address the root cause, it just catches the exception and allows the Enter key press to be processed. An error in the indent strategy shouldn't break the editor.
Comment 4 Nitin Dahyabhai CLA 2009-03-12 00:18:40 EDT
Releasing workaround.
Comment 5 Chris Jaun CLA 2009-04-17 13:37:07 EDT
Nitin, this needs to go into the 3.0.5 steam as well.
Comment 6 Nitin Dahyabhai CLA 2009-04-25 19:26:32 EDT
Similar change made for 3.0.5.