denis-zhdanov / intellij-plugin-copy-on-steroids

Enhances IntelliJ-based IDEs 'Copy' action with ability to deliver rich text (RTF)
13 stars 6 forks source link

java.lang.StringIndexOutOfBoundsException #17

Open dittert opened 11 years ago

dittert commented 11 years ago

I have the following code:

            for (UITestCase testCase : entries)
            {
                out.write("        <tr>\n");
                out.write("            <td class=\" \" style=\"text-align: center\">#" + i + "</td>\n");
                out.write("            <td class=\" \">" + testCase.getTestName() + "(" + testCase.getImages().size() + " Bilder)</td>\n");
                out.write("            <td class=\" \"><a href=\"\">" + testCase.getClassName() + "</a></td>\n");
                out.write("            <td class=\" \">" + testCase.getImages().size() + " Bilder</a></td>\n");
                out.write("        </tr>\n");
                i++;
            }
            out.write(FOOTER);

Select <a href=\"\"> in the snippet above and copy it to the clipboard and you'll get a StringIndexOutOfBoundsException.

Error during dispatching of java.awt.event.KeyEvent[KEY_PRESSED,keyCode=67,keyText=C,keyChar='',modifiers=Strg,extModifiers=Strg,keyLocation=KEY_LOCATION_STANDARD,rawCode=67,primaryLevelUnicode=99,scancode=46,extendedKeyCode=0x43] on frame0: String index out of range: 11 java.lang.StringIndexOutOfBoundsException: String index out of range: 11 at java.lang.String.charAt(String.java:658) at org.denis.view.RtfTransferableData$MyVisitor.visit(RtfTransferableData.java:123) at org.denis.model.Text.invite(Text.java:21) at org.denis.view.RtfTransferableData.content(RtfTransferableData.java:83) at org.denis.view.RtfTransferableData.access$000(RtfTransferableData.java:9) at org.denis.view.RtfTransferableData$1$1.run(RtfTransferableData.java:40) at org.denis.view.RtfTransferableData.rectangularBackground(RtfTransferableData.java:76) at org.denis.view.RtfTransferableData.access$100(RtfTransferableData.java:9) at org.denis.view.RtfTransferableData$1.run(RtfTransferableData.java:37) at org.denis.view.RtfTransferableData.header(RtfTransferableData.java:68) at org.denis.view.RtfTransferableData.build(RtfTransferableData.java:34) at org.denis.view.AbstractSyntaxAwareInputStreamTransferableData.getDelegate(AbstractSyntaxAwareInputStreamTransferableData.java:84) at org.denis.view.AbstractSyntaxAwareInputStreamTransferableData.read(AbstractSyntaxAwareInputStreamTransferableData.java:59) at sun.awt.datatransfer.DataTransferer.translateTransferable(DataTransferer.java:1374) at sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer.java:189) at sun.awt.windows.WClipboard.setContentsNative(WClipboard.java:87) at sun.awt.datatransfer.SunClipboard.setContents(SunClipboard.java:110) at com.intellij.ide.ClipboardSynchronizer$ClipboardHandler.setContent(ClipboardSynchronizer.java:162) at com.intellij.ide.ClipboardSynchronizer.setContent(ClipboardSynchronizer.java:121) at com.intellij.ide.CopyPasteManagerEx.setSystemClipboardContent(CopyPasteManagerEx.java:100) at com.intellij.ide.CopyPasteManagerEx.moveContentTopStackTop(CopyPasteManagerEx.java:270) at com.intellij.ide.CopyPasteManagerEx.a(CopyPasteManagerEx.java:148) at com.intellij.ide.CopyPasteManagerEx.setContents(CopyPasteManagerEx.java:76) at com.intellij.codeInsight.editorActions.CopyHandler.execute(CopyHandler.java:100) at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:82) at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124) 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:564) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:611) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:463) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:206) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:494) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Javaru commented 10 years ago

I had a similar issue. The root of the stack trace is the same: org.denis.view.RtfTransferableData$MyVisitor.visit(RtfTransferableData.java:123)

In my case I simply tried to cut a portion of a regex string out of a Pattern.compile() method. The the string was not cut (from the original text) but it did show on the clipboard (I saw it via my clipboard utility AceText).

===FULL STACK TRACE===

String index out of range: 69: String index out of range: 69 java.lang.StringIndexOutOfBoundsException: String index out of range: 69 at java.lang.String.charAt(String.java:646) at org.denis.view.RtfTransferableData$MyVisitor.visit(RtfTransferableData.java:123) at org.denis.model.Text.invite(Text.java:21) at org.denis.view.RtfTransferableData.content(RtfTransferableData.java:83) at org.denis.view.RtfTransferableData.access$000(RtfTransferableData.java:9) at org.denis.view.RtfTransferableData$1$1.run(RtfTransferableData.java:40) at org.denis.view.RtfTransferableData.rectangularBackground(RtfTransferableData.java:76) at org.denis.view.RtfTransferableData.access$100(RtfTransferableData.java:9) at org.denis.view.RtfTransferableData$1.run(RtfTransferableData.java:37) at org.denis.view.RtfTransferableData.header(RtfTransferableData.java:68) at org.denis.view.RtfTransferableData.build(RtfTransferableData.java:34) at org.denis.view.AbstractSyntaxAwareInputStreamTransferableData.getDelegate(AbstractSyntaxAwareInputStreamTransferableData.java:84) at org.denis.view.AbstractSyntaxAwareInputStreamTransferableData.read(AbstractSyntaxAwareInputStreamTransferableData.java:59) at sun.awt.datatransfer.DataTransferer.translateTransferable(DataTransferer.java:1378) at sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer.java:221) at sun.awt.windows.WClipboard.setContentsNative(WClipboard.java:84) at sun.awt.datatransfer.SunClipboard.setContents(SunClipboard.java:107) at com.intellij.ide.ClipboardSynchronizer$ClipboardHandler.setContent(ClipboardSynchronizer.java:163) at com.intellij.ide.ClipboardSynchronizer.setContent(ClipboardSynchronizer.java:117) at com.intellij.ide.CopyPasteManagerEx.a(CopyPasteManagerEx.java:108) at com.intellij.ide.CopyPasteManagerEx.setContents(CopyPasteManagerEx.java:85) at com.intellij.codeInsight.editorActions.CopyHandler.execute(CopyHandler.java:110) at com.intellij.codeInsight.editorActions.CutHandler.executeWriteAction(CutHandler.java:91) at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.executeWriteAction(EditorWriteActionHandler.java:101) at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:64) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984) at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.doExecute(EditorWriteActionHandler.java:47) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:125) at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:83) at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124) at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:94) at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:68) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:564) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:611) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:463) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:206) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:493) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)