{"action":"opened","issue":{"url":"https://api.github.com/repos/lorenzos/ZenCodingNetBeansPlugin/issues/22","labels_url":"https://api.github.com/repos/lorenzos/ZenCodingNetBeansPlugin/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/lorenzos/ZenCodingNetBeansPlugin/issues/22/comments","events_url":"https://api.github.com/repos/lorenzos/ZenCodingNetBeansPlugin/issues/22/events","html_url":"https://github.com/lorenzos/ZenCodingNetBeansPlugin/issues/22","id":100377634,"number":22,"title":"Java exception on \"wrap with abbreviation\" comand without text selection","user":{"login":"lorenzos","id":245615,"avatar_url":"https://avatars.githubusercontent.com/u/245615?v=3","gravatar_id":"","url":"https://api.github.com/users/lorenzos","html_url":"https://github.com/lorenzos","followers_url":"https://api.github.com/users/lorenzos/followers","following_url":"https://api.github.com/users/lorenzos/following{/other_user}","gists_url":"https://api.github.com/users/lorenzos/gists{/gist_id}","starred_url":"https://api.github.com/users/lorenzos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorenzos/subscriptions","organizations_url":"https://api.github.com/users/lorenzos/orgs","repos_url":"https://api.github.com/users/lorenzos/repos","events_url":"https://api.github.com/users/lorenzos/events{/privacy}","received_events_url":"https://api.github.com/users/lorenzos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-11T18:39:58Z","updated_at":"2015-08-11T18:39:58Z","closed_at":null,"body":"> As reported via email\r\n\r\nNetbeans Version: NetBeans IDE 8.0.2 (Build 201411181905)\r\nJava: 1.8.0_11; Java HotSpot(TM) 64-Bit Server VM 25.11-b03\r\nRuntime: Java(TM) SE Runtime Environment 1.8.0_11-b12\r\n\r\nPlugin version:1.1\r\nSource: Plugin Portal\r\n\r\nstep by step to reproduce:\r\n\r\n 1. open an html file with netbeans. \r\n 2. put the cursor anywhere in the editor without selecting any text.\r\n 3. run the command \"wrap with abbreviation\"\r\n 4. write any tag in the text box. for exemple strong.\r\n 5. clic OK button.\r\n\r\nexpected result (i dont know the specification but I guess there are two options):\r\n\r\n    <tag></tag> is displayed\r\n    ---- or ----\r\n    nothing happens\r\n\r\nseen result:\r\nJava exception (see attached or traces below).\r\n\r\n    Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 12\r\n    at java.lang.String.charAt(String.java:646)\r\n    at org.lorenzos.zencoding.zeneditor.ZenEditor.getIndentation(ZenEditor.java:263)\r\n    at org.lorenzos.zencoding.zeneditor.ZenEditor.replaceContent(ZenEditor.java:107)\r\n\r\n=>  in functions getIndentation, there is :\r\n\r\n    String line = this.getLine();\r\n\r\nthe string \"line\" may contain null or may be empty according to how getLine function works.\r\n\r\nproposed solution :  \r\nI think make null &/or empty string tests before using \"line\" variable or surround the \"while (Character.isWhitespace(line.charAt(i))) ws += line.charAt(i++);\" by try-catch  at least to prevent displaying the exeption in netbeans output to the end user.\r\n\r\n    org.mozilla.javascript.WrappedException: Wrapped java.lang.StringIndexOutOfBoundsException: String index out of range: 12 (zencoding-java.js#3346)\r\n    at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1773)\r\n    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:183)\r\n    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)\r\n    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)\r\n    at org.mozilla.javascript.gen.c1._c138(zencoding-java.js:3346)\r\n    at org.mozilla.javascript.gen.c1.call(zencoding-java.js)\r\n    at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2408)\r\n    at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:282)\r\n    at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)\r\n    at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)\r\n    at org.mozilla.javascript.gen.c1._c104(zencoding-java.js:2632)\r\n    at org.mozilla.javascript.gen.c1.call(zencoding-java.js)\r\n    at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)\r\n    at org.mozilla.javascript.gen.c1._c379(zencoding-java.js:7561)\r\n    at org.mozilla.javascript.gen.c1.call(zencoding-java.js)\r\n    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)\r\n    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)\r\n    at org.mozilla.javascript.gen.c1.call(zencoding-java.js)\r\n    at ru.zencoding.JSExecutor.runAction(JSExecutor.java:75)\r\n    at org.lorenzos.zencoding.actions.ZenCodingAbstractAction$1.run(ZenCodingAbstractAction.java:44)\r\n    at org.netbeans.editor.GuardedDocument.runAtomic(GuardedDocument.java:323)\r\n    at org.openide.text.NbDocument.runAtomic(NbDocument.java:436)\r\n    at org.lorenzos.zencoding.actions.ZenCodingAbstractAction.actionPerformed(ZenCodingAbstractAction.java:49)\r\n    at org.openide.awt.InjectorAny.actionPerformed(InjectorAny.java:73)\r\n    at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:226)\r\n    at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:260)\r\n    at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109)\r\n    at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93)\r\n    at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)\r\n    at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)\r\n    at org.openide.awt.GeneralAction$BaseDelAction.actionPerformed(GeneralAction.java:234)\r\n    at org.openide.windows.TopComponent.processKeyBinding(TopComponent.java:1176)\r\n    at javax.swing.JComponent.processKeyBindings(JComponent.java:2940)\r\n    at javax.swing.JComponent.processKeyEvent(JComponent.java:2842)\r\n    at java.awt.Component.processEvent(Component.java:6304)\r\n    at java.awt.Container.processEvent(Container.java:2234)\r\n    at java.awt.Component.dispatchEventImpl(Component.java:4883)\r\n    at java.awt.Container.dispatchEventImpl(Container.java:2292)\r\n    at java.awt.Component.dispatchEvent(Component.java:4705)\r\n    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)\r\n    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)\r\n    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)\r\n    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)\r\n    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)\r\n    at java.awt.Component.dispatchEventImpl(Component.java:4754)\r\n    at java.awt.Container.dispatchEventImpl(Container.java:2292)\r\n    at java.awt.Window.dispatchEventImpl(Window.java:2739)\r\n    at java.awt.Component.dispatchEvent(Component.java:4705)\r\n    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)\r\n    at java.awt.EventQueue.access$400(EventQueue.java:97)\r\n    at java.awt.EventQueue$3.run(EventQueue.java:697)\r\n    at java.awt.EventQueue$3.run(EventQueue.java:691)\r\n    at java.security.AccessController.doPrivileged(Native Method)\r\n    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)\r\n    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)\r\n    at java.awt.EventQueue$4.run(EventQueue.java:719)\r\n    at java.awt.EventQueue$4.run(EventQueue.java:717)\r\n    at java.security.AccessController.doPrivileged(Native Method)\r\n    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)\r\n    at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)\r\n    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)\r\n    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)\r\n    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)\r\n    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)\r\n    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)\r\n    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)\r\n    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)\r\n    Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 12\r\n    at java.lang.String.charAt(String.java:646)\r\n    at org.lorenzos.zencoding.zeneditor.ZenEditor.getIndentation(ZenEditor.java:263)\r\n    at org.lorenzos.zencoding.zeneditor.ZenEditor.replaceContent(ZenEditor.java:107)\r\n    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n    at java.lang.reflect.Method.invoke(Method.java:483)\r\n    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)\r\n    ... 65 more"}}