Open ghost opened 3 years ago
this offset error seems to also disable diff views (comparing local history). I can do unified view but not side-by-side.
Not sure if I should open a separate issue as I'm guessing its same root cause. Here's the error:
2021-08-28 22:40:07,711 [4906397] ERROR - diff.impl.DiffRequestProcessor - Unexpected termination offset for lexer FlexAdapter for com.mdrobnak.lalrpop.lexer.LalrpopLexer
| java.lang.IllegalStateException: Unexpected termination offset for lexer FlexAdapter for com.mdrobnak.lalrpop.lexer.LalrpopLexer
| at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.doSetText(LexerEditorHighlighter.java:461)
| at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.setText(LexerEditorHighlighter.java:420)
| at com.intellij.openapi.editor.impl.EditorImpl.setHighlighter(EditorImpl.java:1346)
| at com.intellij.diff.util.DiffUtil.setEditorHighlighter(DiffUtil.java:196)
| at com.intellij.diff.util.DiffUtil.configureEditor(DiffUtil.java:263)
| at com.intellij.diff.tools.holders.TextEditorHolder.create(TextEditorHolder.java:97)
| at com.intellij.diff.tools.holders.TextEditorHolder$TextEditorHolderFactory.create(TextEditorHolder.java:107)
| at com.intellij.diff.tools.holders.TextEditorHolder$TextEditorHolderFactory.create(TextEditorHolder.java:101)
| at com.intellij.diff.tools.util.side.TwosideDiffViewer.createEditorHolders(TwosideDiffViewer.java:106)
| at com.intellij.diff.tools.util.side.TwosideTextDiffViewer.createEditorHolders(TwosideTextDiffViewer.java:115)
| at com.intellij.diff.tools.util.side.TwosideDiffViewer.
What version of the plugin are you using?
this was with 0.2.4
, I see you released again I'll try with that and get back to you in the next week or so, but it's unrelated to the replace
feature I think. Thanks.
I tried adding 500 lines containing the following and didn't see any issues:
// Test 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
Unfortunately the stack traces don't give much info about what might be going wrong in my code. This issue gives some possible reasons for the error: https://github.com/antlr/jetbrains-plugin-sample/issues/9
Did you have any unclosed strings or comments when the error occurred?
I just got the same issue again after upgrading lalrpop plugin. No unclosed strings or comments and I still don't know what triggers it. Play around with the code for a bit though and eventually the comments break. Nothing is a long line. I'll just be typing, eventually cause a syntax error and they break. Other times I cause syntax errors and it won't happen.
Sorry, this one is very hard to catch. It may take weeks before I notice a pattern. It is seemingly random! The wrong offset error still prints though - that is the only consistency.
Do you see the problem when you're typing embedded Rust code or LALRPOP code? Or maybe when you go between them?
"Going between them" is probably a more accurate statement. Certainly just typing comments endlessly doesn't seem to trigger it. It's when I'm coding intensely - a lot of changes occurring rapidly, syntax errors, copying and pasting, etc.
That's why it's so difficult to catch. What I may need to do is record my desktop and convert it to a gif while I trigger the behavior, if you're not able to reproduce. Would that be helpful?
That would be helpful, and at very least help document the behavior.
@AzureMarker it may be a while till I screen record, but I did just activate a .lalrpop file that was previously open and all comments highlighting was lost as soon as I typed:
// TODO: use &str instead of String
This time I got logged:
2021-09-08 17:57:50,257 [14208845] ERROR - enapi.editor.impl.DocumentImpl - com.intellij.openapi.editor.ex.util.LexerEditorHighlighter(com.mdrobnak.lalrpop.LpLexerAdaptor): Error updating after DocumentEventImpl[myOffset=279, myOldLength=0, myNewLength=59].
and then:
2021-09-08 17:57:55,051 [14213639] ERROR - chcopy.TextWithMarkupProcessor - IdeaLoggingEvent[message=Error generating text with markup, throwable=java.lang.AssertionError: Unexpected range returned by highlighter: 43:44, prevEnd: 0, scanned range: 242:338, resulting range: 242:44, highlighter: com.intellij.openapi.editor.ex.util.LexerEditorHighlighter(com.mdrobnak.lalrpop.LpLexerAdaptor): 'use std::str::FromStr;
I'll try to do a recording, but that was the simplest scenario I've witnessed so thought to share. The file had been opened for longer and I can't remember all changes I made prior to typing that TODO. When I do record I'll try to start the recording showing freshly loading intellij.
Thanks, looks like there is an issue in the highlighter. I'll take a closer look soon.
Unexpected range returned by highlighter: 43:44, prevEnd: 0
This makes me think that the Rust code sections might be causing the issue. They are handled specially by the lexer (basically as one big token). I can't find any issue just looking at the code though. Additionally, the highlighting lexer is implemented by JetBrains, so there's not much code on my side to mess up. I'll continue looking into this though, thanks for continuing to share details.
Did this issue start happening recently, or has it always been there?
I am now noticing on 0.2.6 IntelliJ shows a baloon message for "IDE FATAL ERRORS" and an UI appears that would normally allow me to send the error report to the author of the plugin, but the "Report and Clear All" button is grayed out (disabled). Anyway you can enable that feature and then I can send you the error report next time?
That's a good idea. I should be able to look into that this week.
I've started looking at this (error reporting). Actually sending the error report is up to the plugin developer, so I'll need to set up something like Sentry or redirect to GitHub issues. Working on that now.
Added the error reporter, will do a release soon: https://github.com/AzureMarker/intellij-lalrpop/commit/7e6c6d18b7216945354d89ee9bf5a8b295f3fb99
Released 0.2.7 with the error reporter.
FYI I think at least one of these exceptions got submitted to Sentry:
I fixed a few other errors I saw in Sentry, and will get to this one hopefully soon.
I think I found a way to reproduce this error. Start with this:
grammar;
Test: () = "test";
Then quickly add an empty code block like so:
grammar;
Test: () = "test" => {};
The error details will show that it got the exception when analyzing the file right before the second curly brace.
I noticed this behavior a while ago, but seems more stable now in the latest release. Maybe okay to close?
I just tried the reproduction steps I posted, and I still see an error. I investigated it a bunch a while ago, but it's really hard to debug since it is almost all in the internals of IntelliJ's lexer code.
I haven't seen the error pop up on Sentry recently, so maybe it's not seen as much in practice anymore.
Hi, I apologize for a vague issue as I still haven't figured out how to reproduce, but if you start typing a lot of comments eventually the syntax highlighting breaks without recovery. This can also be triggered by pasting code into lalrpop files with syntax errors, seemingly randomly.
It may take me weeks till I even realize how to reproduce as it's honestly quite perplexing, but write enough comments
//
or paste enough code into a lalrpop file and this will happen to you.I say this is low priority though since you can fix it simply by restarting intellij. So not a blocker, just an annoyance.
The following error logs are shown, though I'm not sure if or how they are related: