welovecoding / editorconfig-netbeans

A NetBeans IDE plugin supporting the EditorConfig standard. ⛺
https://editorconfig.org/
MIT License
127 stars 22 forks source link

StringIndexOutOfBoundsException while adding more lines to the end of the file #110

Open Chris2011 opened 6 years ago

Chris2011 commented 6 years ago

Because of testing my PR, I added some new lines to the end of the file and I got the following exception. This should not happen.

java.lang.StringIndexOutOfBoundsException: String index out of range: 2664
    at java.lang.String.substring(String.java:1963)
    at com.welovecoding.nbeditorconfig.processor.operation.TrimTrailingWhiteSpaceOperation.detectCaretOffset(TrimTrailingWhiteSpaceOperation.java:51)
    at com.welovecoding.nbeditorconfig.processor.operation.TrimTrailingWhiteSpaceOperation.operate(TrimTrailingWhiteSpaceOperation.java:28)
    at com.welovecoding.nbeditorconfig.processor.operation.TrimTrailingWhiteSpaceOperation.operate(TrimTrailingWhiteSpaceOperation.java:18)
    at com.welovecoding.nbeditorconfig.processor.EditorConfigProcessor.excuteOperations(EditorConfigProcessor.java:192)
    at com.welovecoding.nbeditorconfig.processor.EditorConfigProcessor.applyRulesToFile(EditorConfigProcessor.java:96)
[catch] at com.welovecoding.nbeditorconfig.listener.FileChangeListener.fileChanged(FileChangeListener.java:58)
    at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FileObjectKeeper.fileChanged(FileObjectKeeper.java:365)
    at org.openide.filesystems.FCLSupport$DispatchEventWrapper.dispatchEventImpl(FCLSupport.java:178)
    at org.openide.filesystems.FCLSupport$DispatchEventWrapperSingle.dispatchAllEventsSync(FCLSupport.java:224)
    at org.openide.filesystems.FCLSupport$DispatchEventWrapper.dispatchEvent(FCLSupport.java:137)
    at org.openide.filesystems.FCLSupport.dispatchEvent(FCLSupport.java:105)
    at org.openide.filesystems.FileObject$ED.dispatch(FileObject.java:1398)
    at org.openide.filesystems.EventControl.invokeDispatchers(EventControl.java:213)
    at org.openide.filesystems.EventControl.exitAtomicAction(EventControl.java:188)
    at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:129)
    at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:519)
    at org.openide.filesystems.FileUtil.runAtomicAction(FileUtil.java:420)
    at org.openide.text.DataEditorSupport.saveDocument(DataEditorSupport.java:603)
    at org.netbeans.modules.csl.core.GsfDataObject$GenericEditorSupport$Environment$SaveSupport.save(GsfDataObject.java:224)
    at org.openide.actions.SaveAction.performAction(SaveAction.java:132)
    at org.openide.actions.SaveAction.performAction(SaveAction.java:102)
    at org.openide.actions.SaveAction$Delegate.actionPerformed(SaveAction.java:249)
    at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:231)
    at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:260)
    at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109)
    at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93)
    at org.openide.util.actions.ActionInvoker$ActionRunnable.actionPerformed(ActionInvoker.java:162)
    at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:109)
    at org.netbeans.modules.openide.actions.ActionsBridgeImpl.invokeAction(ActionsBridgeImpl.java:60)
    at org.openide.util.actions.ActionInvoker$ActionRunnable.doRun(ActionInvoker.java:153)
    at org.openide.util.actions.ActionInvoker$2.run(ActionInvoker.java:110)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)

Cheers

Chris

bennycode commented 6 years ago

Hey Chris, this is very valuable debug info! Can you hook up a test case for it?

Chris2011 commented 6 years ago
Chris2011 commented 6 years ago

Smth new here? This and ticket #111 is preventing the most people from using this plugin, I guess.

Chris2011 commented 6 years ago

Nothing new here? Anyone?

Chris2011 commented 5 years ago

Can please someone have a look who has more knowledge about it, than me? @bennyn can you maybe have a look please? Otherwise the plugin will be unusable.

Chris2011 commented 4 years ago

Anything new here?