dmarcotte/idea-handlebars — pull request #28 by dmarcotte (2012-11-12 20:53:26+00:00)
Title: Fix issue in EnterHandler and refactor ActionHandler tests

The Handler which was in charge of smartly inserting an extra newline between open and close block tags errors in the following situation: the caret is at the end of file immediately following an open block expression. i.e.

```
{{#foo}}
```

This pull fixes that issue and refactors action handler tests to be more awesome.

Here's the stack for the error described above:

```
Error during dispatching of java.awt.event.KeyEvent[KEY_PRESSED,keyCode=10,keyText=⏎,keyChar=⏎,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0] on frame13: Wrong line: 7. Available lines count: 7
java.lang.IndexOutOfBoundsException: Wrong line: 7. Available lines count: 7
at com.intellij.openapi.editor.ex.util.SegmentArray.getSegmentStart(SegmentArray.java:266)
at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter$HighlighterIteratorImpl.getStart(LexerEditorHighlighter.java:373)
at com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter$LayeredHighlighterIterator.getStart(LayeredLexerEditorHighlighter.java:510)
at com.dmarcotte.handlebars.editor.actions.HbEnterBetweenTagsHandler.isBetweenHbTags(HbEnterBetweenTagsHandler.java:45)
at com.dmarcotte.handlebars.editor.actions.HbEnterBetweenTagsHandler.preprocessEnter(HbEnterBetweenTagsHandler.java:20)
at com.intellij.codeInsight.editorActions.EnterHandler.a(EnterHandler.java:122)
at com.intellij.codeInsight.editorActions.EnterHandler.access$000(EnterHandler.java:53)
at com.intellij.codeInsight.editorActions.EnterHandler$1.run(EnterHandler.java:71)
at com.intellij.psi.impl.source.PostprocessReformattingAspect$2.compute(PostprocessReformattingAspect.java:101)
at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:110)
at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:98)
at com.intellij.codeInsight.editorActions.EnterHandler.executeWriteAction(EnterHandler.java:69)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:52)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:902)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:36)
at com.intellij.codeInsight.template.impl.editorActions.EnterHandler.executeWriteAction(EnterHandler.java:51)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:52)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:902)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:36)
at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:82)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:117)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:93)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:67)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:542)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:590)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:458)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:206)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:524)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:420)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:378)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
```