-
Notifications
You must be signed in to change notification settings - Fork 248
Bracket/brace filenames break all LSP features #4023
Description
Description
Files with [, ], {, or } in their names (e.g., [id].rb, {slug}.rb) break multiple ruby-lsp features. These filename patterns are common in Rails/Next.js routing conventions.
When such a file exists in the workspace, all LSP features fail for it — indexing, go-to-definition, references, hover, completion, diagnostics, code lens, etc.
Root cause
Two independent issues compound:
-
URI encoding mismatch:
URI::Generic.from_pathincludes[]in its safe character set, so brackets are left unescaped. However, VS Code'svscode-urialways encodes them ([→%5B,]→%5D). This mismatch means the server's URI for a file doesn't match the client's URI, so the document store can't find it. -
Glob metacharacters in paths:
Dir.globtreats[]as character classes and{}as alternation groups. When file or workspace paths containing these characters are interpolated into glob patterns (e.g.,Dir.glob(File.join(workspace_path, "**/*.rb"))), the glob interprets them as pattern syntax rather than literal characters.
Reproduction
- Create a file named
[id].rbin a Ruby project - Open the project in VS Code with ruby-lsp
- Open
[id].rb— observe that no LSP features work (no syntax highlighting from semantic tokens, no go-to-definition, no hover, etc.)
Fix
PR #4022