editorconfig-netbeans icon indicating copy to clipboard operation
editorconfig-netbeans copied to clipboard

StringIndexOutOfBoundsException while adding more lines to the end of the file

Open Chris2011 opened this issue 7 years ago • 6 comments

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

Chris2011 avatar Nov 08 '17 17:11 Chris2011

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

bennycode avatar Nov 08 '17 20:11 bennycode

  • Open a normal json file, like tsconfig.json or package.json for example
  • Set the cursor to the end of the file
  • Hit 4 or 5 times ENTER
  • Save the file
  • Error occurs.

Chris2011 avatar Nov 09 '17 08:11 Chris2011

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

Chris2011 avatar Jun 06 '18 06:06 Chris2011

Nothing new here? Anyone?

Chris2011 avatar Sep 13 '18 14:09 Chris2011

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 avatar Jan 31 '19 12:01 Chris2011

Anything new here?

Chris2011 avatar Apr 22 '20 07:04 Chris2011