Skip to content

hls-rename-plugin: prepareRename returns suboptimal responses #4866

Description

@izuzu-izuzu

Is your enhancement request related to a problem? Please describe.

On textDocument/prepareRename requests, hls-rename-plugin returns either of the following:

  • {defaultBehavior: true} if the cursor is on a Name identifier, which can be renamed
  • {defaultBehavior: false} if the cursor is anywhere else, to signal that renaming is not supported

There are two disadvantages:

  1. HLS depends on the client to support defaultBehavior. (This affected the Zed editor back in 2025, when it did not yet support defaultBehavior.)
  2. HLS does not agree with the LSP specification, which says that if a rename request is invalid, the server should return null. (This affects Emacs users to this day.)

Describe the solution you'd like

prepareRenameProvider should simply return the range of the identifier at the cursor position, using the HIE AST (which it already uses to verify that the cursor is on a Name identifier).

It should also return null for invalid requests.

It might be possible to stop relying on defaultBehavior altogether.

Describe alternatives you've considered

At first I tried just replacing {defaultBehavior: false} with null, but my Emacs setup still occasionally failed to perform renaming.

Additional context

I think there’s none.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions