Skip to content

Comments

[Repo Assist] fix: skip get/set accessor keywords and deduplicate ranges in TextDocumentRename#1453

Merged
Krzysztof-Cieslak merged 2 commits intomainfrom
repo-assist/fix-issue-1269-rename-skip-get-set-accessor-keywords-e093181d5b4e3ed1
Feb 23, 2026
Merged

[Repo Assist] fix: skip get/set accessor keywords and deduplicate ranges in TextDocumentRename#1453
Krzysztof-Cieslak merged 2 commits intomainfrom
repo-assist/fix-issue-1269-rename-skip-get-set-accessor-keywords-e093181d5b4e3ed1

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Closes #1269

Summary

When a property uses explicit getter/setter syntax:

member this.UnsafeValue
    with get () = someField
    and set v = someField <- v

FCS incorrectly returns the get and set accessor keywords as symbol uses of the property name. It may also return duplicate ranges for the property declaration itself. This caused two bugs:

  1. The get and set keywords were incorrectly renamed alongside the property (the reported bug in get () should not be renamed when renaming a property #1269)
  2. Overlapping edits when the same range appears twice in the rename list

Root Cause

SymbolUseWorkspace returns all FCS-identified usages of the symbol, but FCS treats get/set as 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 TextDocumentRename in AdaptiveFSharpLspServer.fs, after retrieving the rename ranges from SymbolUseWorkspace:

  1. Filter out ranges where the source text is "get" or "set" — these are always the accessor keyword, never a valid property name
  2. Deduplicate ranges by start position to avoid overlapping edits

Both 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" in RenameTests.fs verifying that renaming a property with explicit with get () = ... / and set v = ... syntax does not rename the accessor keywords.

Trade-offs

  • The filter is applied purely to the rename edits, not to the FCS data itself — so PrepareRename is unaffected
  • Filtering "get"/"set" is safe because F# does not allow a property to legally be named get or set without backticks, and backtick-quoted \`get``would not match the literal string"get"`

Test Status

  • ✅ Build: dotnet build src/FsAutoComplete/FsAutoComplete.fsproj -f net8.00 errors, 0 warnings
  • ✅ Rename script tests: 18/18 passed (including new regression test) with both TransparentCompiler and BackgroundCompiler backends

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@595b7a9c567ba4dce05ca824aec6e74b4dc545b8. View source at https://github.com/githubnext/agentics/tree/595b7a9c567ba4dce05ca824aec6e74b4dc545b8/workflows/repo-assist.md.

…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>
@github-actions
Copy link
Contributor Author

✅ Pull request created: #1453

@Krzysztof-Cieslak
Copy link
Member

/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>
@github-actions
Copy link
Contributor Author

✅ Commit pushed: 0a6d493

@github-actions
Copy link
Contributor Author

Fix: Fantomas formatting error

The CI "Check format" step was failing because dotnet fantomas --check build.fsx src detected a formatting issue in AdaptiveFSharpLspServer.fs.

Root cause: The let version = ... binding was split across two lines:

let version =
  fileContent |> Option.ofResult |> Option.map (fun f -> f.Version)

But per the .editorconfig setting fsharp_max_value_binding_width=80, Fantomas requires value bindings to stay on a single line when the entire binding is ≤80 characters. The binding let version = fileContent |> Option.ofResult |> Option.map (fun f -> f.Version) is 79 characters, so Fantomas expects it on one line.

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.

Generated by PR Fix for issue #1453

To install this workflow, run gh aw add githubnext/agentics/workflows/pr-fix.md@ee50a3b7d1d3eb4a8c409ac9409fd61c9a66b0f5. View source at https://github.com/githubnext/agentics/tree/ee50a3b7d1d3eb4a8c409ac9409fd61c9a66b0f5/workflows/pr-fix.md.

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • api.nuget.org
  • dc.services.visualstudio.com

@Krzysztof-Cieslak Krzysztof-Cieslak merged commit 7899010 into main Feb 23, 2026
26 checks passed
@Krzysztof-Cieslak Krzysztof-Cieslak deleted the repo-assist/fix-issue-1269-rename-skip-get-set-accessor-keywords-e093181d5b4e3ed1 branch February 23, 2026 12:19
github-actions bot pushed a commit that referenced this pull request Feb 23, 2026
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>
github-actions bot added a commit that referenced this pull request Feb 24, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get () should not be renamed when renaming a property

1 participant