Skip to content
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

LSP crashes when adding or removing lines within code fences #461

Open
2 tasks done
tjex opened this issue Oct 5, 2024 · 3 comments
Open
2 tasks done

LSP crashes when adding or removing lines within code fences #461

tjex opened this issue Oct 5, 2024 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@tjex
Copy link
Member

tjex commented Oct 5, 2024

Check if applicable

  • I have searched the existing issues (required)
  • I'm willing to help fix the problem and contribute a pull request

Describe the bug

While editing within code fences, I'm finding that adding lines (i.e, with <cr> or [o|O]) or removing them (<BS> or dd) that the LSP crashes with "exit code 2 and signal 0".

Here are the lsp logs:

[START][2024-10-05 18:46:43] LSP logging initiated
[ERROR][2024-10-05 18:46:43] .../vim/lsp/rpc.lua:770	"rpc"	"/Users/tjex/.local/share/nvim/mason/bin/marksman"	"stderr"	"[18:46:43 INF] <LSP Entry> Starting Marksman LSP server: {}\n"
[ERROR][2024-10-05 18:46:52] .../vim/lsp/rpc.lua:770	"rpc"	"zk"	"stderr"	"panic: runtime error: slice bounds out of range [:3] with length 0\n\ngoroutine 25 [running"
[ERROR][2024-10-05 18:46:52] .../vim/lsp/rpc.lua:770	"rpc"	"zk"	"stderr"	"]:\ngithub.com/zk-org/zk/internal/adapter/lsp.isLineWithinCodeBlock({0x1400048c000, 0x17, 0x100cf3000?}, 0x1?, {0x140003ec677, 0x6})\n\t/Users/tjex/.local/src/zk-org/zk/main/internal/adapter/lsp/document.go:222 +0x2c8\ngithub.com/zk-org/zk/internal/adapter/lsp.(*document).DocumentLinks(0x140000423c0)\n\t/Users/tjex/.local/src/zk-org/zk/main/internal/adapter/lsp/document.go:262 +0x10c\ngithub.com/zk-org/zk/internal/adapter/lsp.(*Server).refreshDiagnosticsOfDocument.func1()\n\t/Users/tjex/.local/src/zk-org/zk/main/internal/adapter/lsp/server.go:596 +0x70\ncreated by github.com/zk-org/zk/internal/adapter/lsp.(*Server).refreshDiagnosticsOfDocument in goroutine 23\n\t/Users/tjex/.local/src/zk-org/zk/main/internal/adapter/lsp/server.go:589 +0x10c\n"

We worked on code handling links within code fences here, #399. Perhaps this change introduced a bug.

How to reproduce?

  1. Create a new note.
  2. Add code fences with or without lang definition.
  3. Add a line or two within the code fences, delete, add, etc.

At some point the LSP should crash.

If text is added directly at the last line first, and code fences are added then somewhere above it, then the bug doesn't occur.

If the file is saved with text occupying the last line, and then reopened, and a code block is added somewhere above the last line, then the bug does occur.

zk configuration

na

Environment

zk 0.14.1-23-gbe5bd76
system: Darwin 23.6.0 arm64

@tjex tjex added the bug Something isn't working label Oct 6, 2024
@dandeandean
Copy link

Hey @tjex I've been able to reproduce this locally. If you're not actively developing on this, I could pick up this bug.

@tjex tjex added this to the 0.14.2 milestone Jan 18, 2025
@tjex
Copy link
Member Author

tjex commented Jan 18, 2025

@dandeandean I haven't managed to get around to this. It would be incredibly appreciated if you did!

@dandeandean
Copy link

@tjex Sounds good, I am looking into it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants