Skip to content

didChangeWatchedFiles is not sent immediately to LS after applying edits from rename response #1225

Description

@sergeysavchuk

Environment

  • IDE: IntelliJ IDEA Community Edition 2025.2
  • Plugin: lsp4ij 0.14.2
  • OS: macOS

Description

When performing a rename that affects multiple files (many of which are not opened in the IDEA), the subsequent find usages returns only usages from the files that are currently opened. After a significant delay (or after opening the git commit window), the missing usages start to appear.

Preconditions

The symbol to be renamed has usages in several files, including files that are not opened in IDEA.

Steps to Reproduce

  • Open any file in IDEA containing the symbol to be renamed.
  • Run find usages on that symbol and note the total count.
  • Perform rename for that symbol. The language server returns edits that modify multiple files (including unopened files).
  • Immediately run find usages again.

Actual Result

The second find usages lists usages only in opened files (or a subset), so the total count is smaller than before the rename.

After ~60 seconds (in my tests), or earlier if I open the Git Commit window to view pending changes, additional usages appear and the count increases.

Expected Result

The second Find Usages should match the first Find Usages count (pre-rename), reflecting all updated files right away, even if those files are not opened in the editor.

Technical Notes

The edits returned by the language server are applied to files on disk.
However, didChangeWatchedFiles request are not sent to LS immediately.

Also it reproduces with clojure via: https://github.com/clojure-lsp/clojure-lsp-intellij

Activity

  1. angelozerr commented on Aug 20, 2025

    @angelozerr
    Contributor

    Do you rhink you could investigate the problem and create a pr?

  2. angelozerr commented on Aug 20, 2025

    @angelozerr
    Contributor

    If I remember didChangeWatchedFiles uses IJ virtual file listener to know when files changed where events are fired when you do ctrl+s or when you click outside IJ idea.

    Perhaps it is the problem?

  3. sergeysavchuk commented on Aug 20, 2025

    @sergeysavchuk
    ContributorAuthor

    @angelozerr sure, I can investigate this problem over the next few days and will come back with more detailed technical findings.

  4. sergeysavchuk commented on Aug 25, 2025

    @sergeysavchuk
    ContributorAuthor

    @angelozerr Yes, you are right it's related to saving. I've submitted a PR that adds immediate document saving to fix this behavior. Could you please review it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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