Skip to content
Open
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
5 changes: 4 additions & 1 deletion src/Compiler/Checking/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,8 @@ type TcResultsSinkImpl(tcGlobals, ?sourceText: ISourceText) =
let capturedOpenDeclarations = ResizeArray<OpenDeclaration>()
let capturedFormatSpecifierLocations = ResizeArray<_>()

let capturedFormatSpecifierRanges = HashSet<range>()

let capturedNameResolutionIdentifiers =
HashSet<pos * string>
{ new IEqualityComparer<_> with
Expand Down Expand Up @@ -2289,7 +2291,8 @@ type TcResultsSinkImpl(tcGlobals, ?sourceText: ISourceText) =
capturedMethodGroupResolutions.Add(CapturedNameResolution(itemMethodGroup, [], occurrenceType, nenv, ad, m))

member sink.NotifyFormatSpecifierLocation(m, numArgs) =
capturedFormatSpecifierLocations.Add((m, numArgs))
if capturedFormatSpecifierRanges.Add(m) then
capturedFormatSpecifierLocations.Add((m, numArgs))

member sink.NotifyRelatedSymbolUse(m, item, kind) =
if allowedRange m then
Expand Down
13 changes: 13 additions & 0 deletions tests/FSharp.Compiler.Service.Tests/EditorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,19 @@ let _ = debug "[LanguageService] Type checking fails for '%s' with content=%A an
(4, 82, 4, 84, 1);
(4, 108, 4, 110, 1)|]

[<Fact>]
let ``Format specifier locations not duplicated in CE`` () =
let input = "let _ = seq { sprintf \"%d\" 1 }"
let file = "/home/user/Test.fsx"
let _parseResult, typeCheckResults = parseAndCheckScript(file, input)

let locations = typeCheckResults.GetFormatSpecifierLocationsAndArity()
let percentD =
locations
|> Array.filter (fun (r, _) -> r.StartColumn = 23)

Assert.Equal(1, percentD.Length)

#if ASSUME_PREVIEW_FSHARP_CORE
[<Fact>]
let ``Printf specifiers for regular and verbatim interpolated strings`` () =
Expand Down
Loading