-
Notifications
You must be signed in to change notification settings - Fork 15
fix: hide virtual documents when their LSP is not installed #102
base: main
Are you sure you want to change the base?
Conversation
Hide and make the buffer readonly when we ensure the virtual document is open. This is mosty to prevent the html virtual document to be visible when the html lsp is not available, as rzls works fine without it.
WalkthroughBuffer option configuration for C# and HTML virtual documents has been relocated from LSP attach autocmd to the buffer initialization phase, applying Changes
Sequence Diagram(s)sequenceDiagram
participant caller as Caller
participant ensure as ensure_open
participant lsp as LSP
rect rgb(220, 240, 230)
Note over ensure,lsp: NEW: Options set during initialization
caller->>ensure: register_vbufs_by_path()
ensure->>ensure: Open buffer
ensure->>ensure: Set buftype=nowrite<br/>buflisted=false
end
ensure-->>lsp: LSP attach event
Note over lsp: Autocmd removed<br/>(no longer needed)
rect rgb(240, 220, 220)
Note over ensure,lsp: OLD: Options set on LSP attach
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lua/rzls/documentstore.lua (1)
66-75: C# virtual buffer nowrite/unlisted config looks correct and aligns with the PR goalMoving the
buftype=nowriteandbuflisted=falsesettings intoregister_vbufs_by_pathfor the C# URI (and scoping them with{ buf = buf }) ensures the Razor C# virtual buffer stays hidden/unlisted even when no C#/Roslyn LSP attach event runs. This matches the intent of keeping these internal buffers out of the normal buffer list and non-writable to disk.If you want to trim duplication with the HTML block below, you could factor these three option calls into a small helper like
configure_virtual_vbuf(buf, ft)and reuse it for both C# and HTML.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lua/rzls/documentstore.lua(2 hunks)
🔇 Additional comments (1)
lua/rzls/documentstore.lua (1)
90-99: HTML virtual buffer configuration mirrors C# and should prevent visibility without HTML LSPThis block mirrors the C# handling: setting
filetype=html,buftype=nowrite, andbuflisted=falseon the HTML virtual buffer atensure_opentime makes it an internal, unlisted buffer regardless of whether an HTML LSP is installed or attaches. That should address the issue of the HTML virtual document becoming visible when the HTML LSP isn’t present, while keeping behavior consistent with the C# virtual document.If you introduce a helper for the C# block (e.g.,
configure_virtual_vbuf(buf, "cs"|"html")), you can reuse it here to keep these paths in lockstep.
|
IIRC, it used to be like this. But it creates a bit of a race condition, as I think the LSP client wont attach to unlisted buffers. So we need the client to be attached before we unlist. That might have changed since in which case this is much better |
|
Yeah, I imagined it that would be the reason, but I could not break it in any way. But race conditions are just like that :) |
Hide and make the buffer readonly when we ensure the virtual document is open. This is mosty to prevent the html virtual document to be visible when the html lsp is not available, as rzls works fine without it.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.