Renaming constructor makes undesirable whitespace changes / removal of .. from Record wildcard pattern matches {..}
After fixing https://github.com/haskell/haskell-language-server/issues/2915 in https://github.com/haskell/haskell-language-server/pull/4635 I noticed the following issues when RecordWildcard pattern matches are used and record constructor is renamed.
This issue seems to only affect GHC 9.6 and 9.8 (in 9.10+ it works fine).
Your environment
Which OS do you use?
Which version of GHC do you use and how did you install it?
How is your project built (alternative: link to the project)?
Which LSP client (editor/plugin) do you use? VSCode
Which version of HLS do you use and how did you install it? 2.10.0.0 + latest changes from master
Have you configured HLS in any way (especially: a hie.yaml file)?
No
Steps to reproduce
See reproducer marked as broken in https://github.com/haskell/haskell-language-server/pull/4635/files#diff-ecd5eff03edc6cac02343f9fe14aeb61fa616f9069e4b3db048d13affb648d17R29-R31
Expected behaviour
When renaming constructor, wildcard pattern matches should not be touched:
OriginalConstructor {..} -> RenamedConstructorToLongerName {..}
OriginalConstructor {..} -> ShortRenmd {..}
Actual behaviour
2 cases of issues happen when renaming the constructor:
OriginalConstructor {..} -> RenamedConstructorToLongerName{} -- notice that `..` are removed
OriginalConstructor {..} -> ShortRenmd { ..} -- undesirable whitespace is introduced
Debug information
When renaming we should filter out the {..} reference too. One possible solution is a direct text comparison to see if the relevant location actually contains the field name. I wonder if there is a better solution than it.
There is something different between ghc 9.6 / 9.8 where this is broken and 9.10/9.12 where it works. I haven't looked more deeply into where the difference is coming from, but this is the thing I'd start with before attempting a fix.