-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix LSP Crash in Code Fences #493
Conversation
…d... under same circumstances as before
Great, thanks for this!! There's been a lot of activity here all of sudden, and I'm a little down on free time at the moment. So just a heads up that I may take a bit to get around to this. |
So the test-note.md is causing the crash for me as expected. Do you understand why the crash is happening? I feel like it would be great to just hit the nail on the head with this from the start, instead of a hot fix. |
@tjex That's a fair point. I haven't been working on this, but I can pick up on this again & try to find a more robust solution. I was being lazy & trying to get away with just fixing the crashing conditions. It's strange that it's still crashing for you... how did you test it? |
Ah sorry. I meant that I tested the functionality of the test-note to recreate a crash. And that worked. If you wanted to do so that would be awesome. I can help along the way. But sporadically... Still getting to grips with the new job and balancing a masters thesis on the side. But this bug is a high priority for me. |
@tjex I've been looking this week trying to find out what causes these crashing conditions, but no dice. The problematic function is We also call this Do you have any insight into when this |
Hey @tjex, after some more investigation (and a whole bunch of print debugging), I am pretty sure the fix was way more simple than I initially though. See the updated the description & the test files. After compiling & attaching this version of the LSP, I haven't had any crashes. |
Ooooooh dayum. That's a nice turn of events! Will check it out after dinner / tomorrow. |
All working on my end. Well done and thanks again! |
Description
This PR fixes the crash described in #461.
The root cause of the problem was that the global state that tracks whether or not a line is in a code fence was not reset after each pass over the file. This behavior can be shown in the
test-wrap.md
file.This would cause the
currentCodeBlockStart
to not always point to the fence.Sometimes it would point to a line with len < 3, which resulted in a out of bounds read in
lines[currentCodeBlockStart][:3] == line[:3]
.Another undefined state caused by this is where
lineIndex
<currentCodeBlockStart
.Testing:
I manually tested by attaching the lsp to
nvim 0v0.10.4
on the following files:test-note.md
test-fence.md
test-wrap.md