Add Extract to let binding and Extract to literal refactorings - #20537
Open
xperiandri wants to merge 6 commits into
Open
xperiandri wants to merge 6 commits into
xperiandri wants to merge 6 commits into
Conversation
…g or a literal The selected expression is bound to a new name in front of the statement that uses it: above a statement that starts its line, or, when the body of a binding, match clause, branch or lambda shares the line with its keyword, on new lines under that keyword. A constant inside a module-level declaration can instead become a [<Literal>] in front of that declaration. The shared selection and placement logic lives in Refactor/RefactoringHelpers.fs, and the refactoring test framework gains helpers that run a provider on a selected span. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
|
xperiandri
commented
Sep 14, 2026
|
|
||
| tryGetRefactoringActionsForSpan code (selectionOf code selected) context (new FSharpExtractLetBindingRefactoring()) | ||
| |> Seq.map _.Title | ||
| |> List.ofSeq |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| |> List.ofSeq | |
| |> Seq.toList |
C# offers Introduce Constant without a selection. With a caret alone only the literal is offered; a let binding still needs a selection. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A caret between 'fun' and the end of '->' acts as a selection of the parenthesized lambda; in the body a caret offers nothing new. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…e of its section Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
xperiandri
marked this pull request as ready for review
September 14, 2026 19:40
Contributor
|
🔍 Tooling Safety Check — Affects-Design-Time
|
T-Gro
requested changes
Sep 15, 2026
T-Gro
left a comment
Member
There was a problem hiding this comment.
🤖🕵️ Please shorten the description using this guidance. Focus on the problem and why the change is needed, in simplified technical English. Leave the implementation inventory to the Files tab and retain necessary caveats.
Contributor
Author
Covered casesOffered
Not offered
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Offers
Ctrl+.on a selected expression to bind it to aletin front of the statement that uses it, or, for a constant in a module-level declaration, to a[<Literal>]above that declaration. A caret inside a constant offers the literal; a caret in thefun … ->header of a parenthesized lambda extracts the lambda.The value is computed at the start of the enclosing statement, so it can run earlier than where it was written, as with C#'s Introduce Local. The selection must match a whole expression; nothing is offered inside quotations, interpolation holes,
whileconditions orwhenguards.🤖 Generated with Claude Code