Skip to content

Handle file renaming - #4957

Open
VeryMilkyJoe wants to merge 1 commit into
haskell:masterfrom
VeryMilkyJoe:rename-decl-imports
Open

Handle file renaming#4957
VeryMilkyJoe wants to merge 1 commit into
haskell:masterfrom
VeryMilkyJoe:rename-decl-imports

Conversation

@VeryMilkyJoe

@VeryMilkyJoe VeryMilkyJoe commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Adds handling of WillRenameFile Notification to the rename plugin.

When receiving this notification, we:

  • change the module name to the new file name in the module declaration of the renamed file, and
  • change all imports of the renamed file to the new name.

Note that in the example below, there are errors after renaming because we do not edit the cabal file so the project will not build after a rename.

This is part of the implementation of #4951.

Screencast.From.2026-06-07.15-09-27.mp4

@VeryMilkyJoe
VeryMilkyJoe force-pushed the rename-decl-imports branch 4 times, most recently from 406eac2 to 95f99f3 Compare June 8, 2026 08:08
@VeryMilkyJoe
VeryMilkyJoe force-pushed the rename-decl-imports branch 2 times, most recently from e521a2a to 674a1b9 Compare June 8, 2026 12:04
Comment thread plugins/hls-rename-plugin/src/Ide/Plugin/Rename/ModuleName.hs Outdated
Add handling of WillRename Notification which changes the module
declaration and all imports of the module to rename to the new name.

@dyniec dyniec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Could use small test like: Foo imports Bla, Bla is renamed to Bar, and check that now Foo imports Bar, and Bar is Bar.

Now that #4961 is merged those squiggles in demo would disappear?

@VeryMilkyJoe

Copy link
Copy Markdown
Collaborator Author

Looks good. Could use small test like: Foo imports Bla, Bla is renamed to Bar, and check that now Foo imports Bar, and Bar is Bar.

Now that #4961 is merged those squiggles in demo would disappear?

Yes, I am planning to add tests still!

The squiggles are due to the session not being reloaded, I plan to open the next PR, which reloads the session after a rename has been completed, after this one.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants