Skip to content
This repository has been archived by the owner on Apr 10, 2021. It is now read-only.

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

Open
Chris2011 opened this issue Nov 8, 2017 · 6 comments

Comments

@Chris2011
Copy link
Contributor

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
Copy link
Member

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

@Chris2011
Copy link
Contributor Author

  • 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
Copy link
Contributor Author

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

@Chris2011
Copy link
Contributor Author

Nothing new here? Anyone?

@Chris2011
Copy link
Contributor Author

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
Copy link
Contributor Author

Anything new here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants