Skip to content

Bracket/brace filenames break all LSP features #4023

@andriytyurnikov

Description

@andriytyurnikov

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:

  1. URI encoding mismatch: URI::Generic.from_path includes [] in its safe character set, so brackets are left unescaped. However, VS Code's vscode-uri always 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.

  2. Glob metacharacters in paths: Dir.glob treats [] 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

  1. Create a file named [id].rb in a Ruby project
  2. Open the project in VS Code with ruby-lsp
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions