Skip to content

Enabling onTypeFormatting LSP feature in Ruby LSP causes issues #38

Open
@vitallium

Description

@vitallium

It was reported via Reddit that onTypeFormatting (enabled by default) LSP feature in Ruby LSP causes issues:

Image

Why? Ruby LSP tries to improve UX and complete block params automatically. Here is how it look in VSCode:

Image

This is done by sending the following response:

[
    {
        "range": {
            "start": {
                "line": 1,
                "character": 12
            },
            "end": {
                "line": 1,
                "character": 12
            }
        },
        "newText": "|"
    },
    {
        "range": {
            "start": {
                "line": 1,
                "character": 12
            },
            "end": {
                "line": 1,
                "character": 12
            }
        },
        "newText": "$0"
    }
]

Specifically the last TextEdit command breaks bevahior in Zed:

    {
        "range": {
            "start": {
                "line": 1,
                "character": 12
            },
            "end": {
                "line": 1,
                "character": 12
            }
        },
        "newText": "$0"
    }

This commands moves the cursor to the $0 the final cursor position. $0 is a part of the LSP Snippets.

Workaround

The workaround is to disable onTypeFormatting via Zed settings like this:

{
  "lsp": {
    "ruby-lsp": {
      "initialization_options": {
        "enabledFeatures": {
          "onTypeFormatting": false
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstream::ruby-lspruby-lsp issue (not extension)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions