[Repo Assist] fix: skip get/set accessor keywords and deduplicate ranges in TextDocumentRename#1453
Conversation
…umentRename When a property uses explicit getter/setter syntax: member this.Prop with get () = ... and set v = ... FCS incorrectly returns the 'get' and 'set' keywords as symbol uses of the property name. It may also return duplicate ranges for the property declaration itself. This caused: - The 'get' and 'set' keywords to be incorrectly renamed alongside the property - Overlapping edits when the same range appears twice Fix: filter out ranges whose source text is 'get' or 'set', and deduplicate ranges by start position before applying rename edits. Fixes #1269 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Pull request created: #1453 |
|
/pr-fix |
The fsharp_max_value_binding_width=80 setting in .editorconfig requires value bindings whose expression fits within 80 chars to stay on a single line. The expression is 65 chars, so the entire binding (79 chars) fits on one line. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Commit pushed: |
Fix: Fantomas formatting errorThe CI "Check format" step was failing because Root cause: The let version =
fileContent |> Option.ofResult |> Option.map (fun f -> f.Version)But per the Fix: Collapsed the binding to a single line: let version = fileContent |> Option.ofResult |> Option.map (fun f -> f.Version)The logic and functionality of the PR remain unchanged.
Warning
|
Summarise changes merged since v0.83.0: - Fix SourceLink go-to-def on .NET 10 Linux (#1441) - Add backgroundServiceProgress config option (#1452) - Fix { trigger char for interpolated strings (#1454) - Fix non-ASCII URI encoding (#1455) - Fix spurious get/set rename (#1453) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Include all PRs merged since v0.83.0: - #1441: Fix SourceLink go-to-def failure on .NET 10 on Linux - #1452: Add FSharp.notifications.backgroundServiceProgress config option - #1449: Fix semantic token multiline range uint32 underflow - #1453: Fix spurious get/set rename in TextDocumentRename - #1454: Fix missing { interpolated string completion trigger - #1455: Fix non-ASCII path encoding in file URIs - #1456: Disable inline values by default to restore pipeline hints - #1457: Fix missing parens in function-type segments in AddExplicitTypeAnnotation - #1458: Fix signature help parameter types showing fully-qualified names - #1463: Fix seealso href/langword XML doc rendering Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #1269
Summary
When a property uses explicit getter/setter syntax:
FCS incorrectly returns the
getandsetaccessor keywords as symbol uses of the property name. It may also return duplicate ranges for the property declaration itself. This caused two bugs:getandsetkeywords were incorrectly renamed alongside the property (the reported bug inget ()should not be renamed when renaming a property #1269)Root Cause
SymbolUseWorkspacereturns all FCS-identified usages of the symbol, but FCS treatsget/setas part of the property's accessor chain and includes those keyword positions as rename targets. Additionally, duplicate ranges can be returned for the same position in some cases.Fix
In
TextDocumentRenameinAdaptiveFSharpLspServer.fs, after retrieving the rename ranges fromSymbolUseWorkspace:"get"or"set"— these are always the accessor keyword, never a valid property nameBoth operations fall back gracefully if the file source can't be read (no filtering/dedup in the error case).
Test
Added regression test
"renaming property with explicit get/set does not rename accessor keywords"inRenameTests.fsverifying that renaming a property with explicitwith get () = .../and set v = ...syntax does not rename the accessor keywords.Trade-offs
PrepareRenameis unaffected"get"/"set"is safe because F# does not allow a property to legally be namedgetorsetwithout backticks, and backtick-quoted\`get``would not match the literal string"get"`Test Status
dotnet build src/FsAutoComplete/FsAutoComplete.fsproj -f net8.0— 0 errors, 0 warnings