Skip to content

Code completion: prefer the first naming environment for range #18516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ type internal TypeCheckInfo
if rangeContainsPos mPossible cursorPos then
match bestSoFar with
| Some(bestm, _, _) ->
if rangeContainsRange bestm mPossible then
if rangeContainsRange bestm mPossible && not (equals bestm mPossible) then
bestSoFar <- Some(mPossible, env, ad)
| None -> bestSoFar <- Some(mPossible, env, ad))

Expand Down
22 changes: 22 additions & 0 deletions tests/FSharp.Compiler.Service.Tests/CompletionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,25 @@ let f (s: string) =
()
"""
assertHasItemWithNames ["Length"] info


[<Fact>]
let ``Import - Ns 01`` () =
let info =
getCompletionInfo "let _: R " (14, 12) """
namespace Ns

type Rec1 = { F: int }


namespace Ns

type Rec2 = { F: int }

module M =

type Rec3 = { F: int }

let _: R = ()
"""
assertHasItemWithNames ["Rec1"; "Rec2"; "Rec3"] info
Loading