idea-batch
idea-batch copied to clipboard
typing :: breaks the editor
Hey, using PhpStorm 2019.3.4 on Win10 Pro.
Whenever I try to type :: (double colon) the editor breaks after the first : character and syntax highlighting after the cursor is gone. Return/Enter/Arrow keys are the only ones working, all printable character don't.
I need to reopen the file to continue.
The log reports java.lang.IndexOutOfBoundsException: Wrong offset: 681. Should be in range: [0, 655], full log below.
This has also been reported on July 02, 2019 by another user in the JetBrains forum IntelliJ Stopped Editor Working
I can use REM, however :: is just muscle memory.
And it would be nice to have standard Ctrl+/ to comment lines, see #42
java.lang.IndexOutOfBoundsException: Wrong offset: 681. Should be in range: [0, 655]
at com.intellij.openapi.editor.ex.util.SegmentArray.offsetOutOfRange(SegmentArray.java:90)
at com.intellij.openapi.editor.ex.util.SegmentArray.findSegmentIndex(SegmentArray.java:104)
at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.getTokenType(LexerEditorHighlighter.java:497)
at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.getAttributesForPreviousAndTypedChars(LexerEditorHighlighter.java:481)
at com.intellij.openapi.editor.impl.ImmediatePainter.paintImmediately(ImmediatePainter.java:125)
at com.intellij.openapi.editor.impl.ImmediatePainter.paint(ImmediatePainter.java:80)
at com.intellij.openapi.editor.impl.EditorImpl.processKeyTypedImmediately(EditorImpl.java:1283)
at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:1268)
at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:3349)
at com.intellij.openapi.editor.impl.EditorImpl$7.keyTyped(EditorImpl.java:1104)
at java.desktop/java.awt.Component.processKeyEvent(Component.java:6606)
at java.desktop/javax.swing.JComponent.processKeyEvent(JComponent.java:2849)
at java.desktop/java.awt.Component.processEvent(Component.java:6428)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5026)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1950)
at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:878)
at java.desktop/java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1148)
at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1017)
at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:843)
at com.intellij.ide.IdeKeyboardFocusManager.dispatchEvent(IdeKeyboardFocusManager.java:40)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4907)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:908)
at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:834)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:775)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:424)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:698)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:423)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
I can't reproduce the error. I can type :: without any error and the text behind it is marked as comment how it should.
That's "unfortunate" 'cos it happens to me on any .cmd file.
Which got me thinking while writing this ...
- It works if the file name suffix is
.bat
That's unfortunate, too, 'cos I use .cmd since Windows NT 4 to distinguish them from Win 9.x files back in the days. AFAIK that's also the recommended suffix for NT-ish flavours since ever.
addendum: if I creat e .bat file and rename it to .cmd (Shift+F6) it still works. It only breaks if the file suffix was .cmd in the first place.
That's crazy. Maybe you can provide a PR? Another odd thing is, that in your provided stack trace no classes of this plugin are mentioned. So I don't think it's a problem of this plugin.
I just dumped the log that poped up when the editor broke. Not sure if something else happend at the same moment or if I missed an entry.
To make things more okkult: once I renamed the test .bat back and forth to .cmd all existing .cmd files suddenly worked as well in the same session. If I restart PhpStorm (Invalidate Caches and Restart) things break again.
This time I got two backtraces:
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'tokenType' of com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.getAttributes must not be null
com.intellij.openapi.editor.ex.util.LexerEditorHighlighter$InvalidStateException: com.intellij.openapi.editor.ex.util.LexerEditorHighlighter(org.intellij.lang.batch.lexer.BatchHighlighterLexer): Error updating after DocumentEventImpl[myOffset=123, myOldLength=1, myNewLength=0, myOldString='
The second is followed by a truncated ("... 43 more")
Caused by: java.lang.IndexOutOfBoundsException: Wrong offset: 123. Should be in range: [0, 112]
Both mention the "Lexer" as in the JetBrain forum. I can post the full log for both if that's of any help.
Yes, please post the full stack traces
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'tokenType' of com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.getAttributes must not be null
This is inside of intellij if you look at the package com/intellij/openapi
The second one is more interesting thought, because there is our package org.intellij.lang.batch mentioned
There you go; it stops after the "... 43 more" though:
com.intellij.openapi.editor.ex.util.LexerEditorHighlighter$InvalidStateException:
com.intellij.openapi.editor.ex.util.LexerEditorHighlighter(org.intellij.lang.batch.lexer.BatchHighlighterLexer):
Error updating after DocumentEventImpl[myOffset=123, myOldLength=1, myNewLength=0, myOldString='
', myNewString=''].
at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.documentChanged(LexerEditorHighlighter.java:337)
at com.intellij.openapi.editor.impl.DocumentImpl.changedUpdate(DocumentImpl.java:899)
at com.intellij.openapi.editor.impl.DocumentImpl.updateText(DocumentImpl.java:803)
at com.intellij.openapi.editor.impl.DocumentImpl.deleteString(DocumentImpl.java:583)
at com.intellij.openapi.command.impl.EditorChangeAction.exchangeStrings(EditorChangeAction.java:86)
at com.intellij.openapi.command.impl.EditorChangeAction.performUndo(EditorChangeAction.java:63)
at com.intellij.openapi.command.impl.EditorChangeAction.undo(EditorChangeAction.java:50)
at com.intellij.openapi.command.impl.UndoableGroup.performActions(UndoableGroup.java:179)
at com.intellij.openapi.command.impl.UndoableGroup.lambda$doUndoOrRedo$0(UndoableGroup.java:151)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:885)
at com.intellij.openapi.command.impl.UndoableGroup.doUndoOrRedo(UndoableGroup.java:128)
at com.intellij.openapi.command.impl.UndoableGroup.undoOrRedo(UndoableGroup.java:117)
at com.intellij.openapi.command.impl.UndoableGroup.undo(UndoableGroup.java:96)
at com.intellij.openapi.command.impl.Undo.performAction(Undo.java:40)
at com.intellij.openapi.command.impl.UndoRedo.execute(UndoRedo.java:132)
at com.intellij.openapi.command.impl.CommandMerger.undoOrRedo(CommandMerger.java:220)
at com.intellij.openapi.command.impl.UndoManagerImpl.lambda$undoOrRedo$0(UndoManagerImpl.java:354)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:220)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:178)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:168)
at com.intellij.openapi.command.impl.UndoManagerImpl.undoOrRedo(UndoManagerImpl.java:362)
at com.intellij.openapi.command.impl.UndoManagerImpl.undo(UndoManagerImpl.java:337)
at com.intellij.ide.actions.UndoAction.perform(UndoAction.java:30)
at com.intellij.ide.actions.UndoRedoAction.actionPerformed(UndoRedoAction.java:43)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:298)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:315)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:604)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$processAction$3(IdeKeyEventDispatcher.java:657)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:193)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:656)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:517)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:472)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:221)
at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:830)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:775)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:424)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:698)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:423)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.IndexOutOfBoundsException: Wrong offset: 123. Should be in range: [0, 112]
at com.intellij.openapi.editor.ex.util.SegmentArray.offsetOutOfRange(SegmentArray.java:90)
at com.intellij.openapi.editor.ex.util.SegmentArray.findSegmentIndex(SegmentArray.java:104)
at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.documentChanged(LexerEditorHighlighter.java:167)
... 43 more
Here's another goodie. Consider this content
@echo off
REM a remarkable remark
REM with two lines
echo %~0
goto :EOF
If I select any of the REM and type :: over the selection, it gets replaced as expected and everything is fine, the two colons show up and syntax highlighting stays intact.
If I put the cursor i.e. after the ECHO line, without making a selection, things break instantly after the first :.
Also the line beneath goto :EOF gets red squigly lines like a syntax error inspection, but there's neither a red lightbulp nor do Ctrl+F1 or Alt+Enter provide any insight.
Hope this helps! Enjoy, good luck and stay healthy! 🤧😷
Hello, I am suffering the same problem and I can share my code
::===============================================================
:: Run Workflow to middle screen
::===============================================================
ECHO OFF
:: Windows Version Check
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
START "" "C:\Users\AnthonyPC\AppData\Local\Postman\Postman.exe"
START "" "C:\Users\AnthonyPC\AppData\Local\Obsidian\Obsidian.exe"
START "" "C:\Users\AnthonyPC\OneDrive\Desktop\Programas\Outlook"
START chrome /profile-directory="Profile 3"
idea
EXIT
The problem is when I want to write :: before to START this considers all the code below as if it were the comment and highlights it in red, that is, it does not consider the line itself, but everything that is from that line down