Skip to content

Inconsistent LSP: Rename behaviour #192

@martinstark

Description

@martinstark

Describe the bug

I ran into an issue where if I run LSP: Rename once on a property it detects 10 occurrences across 8 files. I then run LSP: Rename again on the same (just renamed) property and it only detects 2 occurrences across 2 files.

I'm in a monorepo project structured like so:

// rootFolder is set up as sublime project root

rootFolder/package1/src // source files
rootFolder/package1/dist // locally compiled package
rootFolder/package2/src // depends on package1
rootFolder/package2/dist
rootFolder/package3/src // depends on package1 and 2
rootFolder/package3/dist
// etc

The second run of LSP: Rename seems to only find occurrences within the package path that the property to be renamed originates from, e.g. package1.

I understand that the monorepo structure with adjacent packages consuming the locally built /dist folders requires restarts of the LSP server after re-building the project. WebStorm handles this without issues when performing refactor/renaming, but I'm trying to migrate to Sublime.

For a couple of rounds it consistently worked, by making sure that I:

  1. do LSP: Rename (detect 10 occurrences across 8 files)
  2. rebuild project to make new type definitions available to adjacent packages
  3. restart LSP TypeScript server to pick up file changes
  4. do LSP: Rename again to "revert" the changes (detect 10/8)
  5. rebuild project
  6. restart LSP TypeScript server
  7. ...

After a couple of runs it starts detecting only 2 occurrences, and I can't get it to detect all 10/8 by rebuilding project, restarting LSP server, or restarting Sublime.

If I open a project file that references the property I'm trying to edit, then go back to edit the type definition via LSP: Rename, it will now detect 3 occurrences across 3 files. If I keep opening the files I know reference the property LSP: Rename will eventually detect all of them again. If I trigger LSP: Rename in a different file referencing the same property, it will sometimes go back to detecting all occurrences, and sometimes detect its own subset of occurrences within its package.

To Reproduce

Steps to reproduce the behaviour:

  1. Open a TypeScript monorepo as a project in Sublime
  2. Build and install dependencies
  3. Perform a LSP: Rename on a property that is used across multiple package folders
  4. See it correctly find all references
  5. Save All
  6. Re-build the project
  7. Restart LSP-Typescript server
  8. Perform a LSP: Rename on the same property (that now has a new name)
  9. ... repeat steps 3 through 9 some number of times
  10. See LSP: Rename fail to correctly find all references

Expected behavior
LSP: Rename should find all references to a property every time it is run.

Screenshots
n/a

Environment (please complete the following information):

  • OS: Arch Linux
  • Sublime Text version: 4143
  • LSP version: 1.21.0
  • Language servers used: LSP-Typescript, LSP-Eslint

Additional context
n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions