Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 749ba2d

Browse files
OmarTawfikKevinRansom
authored andcommitted
Don't match braces at the end of the caret (dotnet#1619)
1 parent 00bab99 commit 749ba2d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

vsintegration/src/FSharp.Editor/BraceMatchingService.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type internal FSharpBraceMatchingService() =
1414
static member GetBraceMatchingResult(sourceText, fileName, options, position) = async {
1515
let isPositionInRange(range) =
1616
let span = CommonRoslynHelpers.FSharpRangeToTextSpan(sourceText, range)
17-
span.Start <= position && position <= span.End
17+
span.Start <= position && position < span.End
1818
let! matchedBraces = FSharpChecker.Instance.MatchBracesAlternate(fileName, sourceText.ToString(), options)
1919

2020
return matchedBraces |> Seq.tryFind(fun(left, right) -> isPositionInRange(left) || isPositionInRange(right))

vsintegration/tests/unittests/BraceMatchingServiceTests.fs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,17 @@ type BraceMatchingServiceTests() =
139139
let x = \"stringValue\" + (endsInString +
140140
\" )endsInString <startsInString \" +
141141
+ >startsInString"
142-
this.VerifyNoBraceMatch(code, startMarker)
142+
this.VerifyNoBraceMatch(code, startMarker)
143+
144+
[<Test>]
145+
member this.BraceMatchingAtEndOfLine_Bug1597() =
146+
// https://github.com/Microsoft/visualfsharp/issues/1597
147+
let code = """
148+
[<EntryPoint>]
149+
let main argv =
150+
let arg1 = ""
151+
let arg2 = ""
152+
let arg3 = ""
153+
(printfn "%A '%A' '%A'" (arg1) (arg2) (arg3))endBrace
154+
0 // return an integer exit code"""
155+
this.VerifyBraceMatch(code, "(printfn", ")endBrace")

0 commit comments

Comments
 (0)