Skip to content

Commit

Permalink
Don't match braces at the end of the caret (dotnet#1619)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarTawfik authored and KevinRansom committed Oct 15, 2016
1 parent 00bab99 commit 749ba2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vsintegration/src/FSharp.Editor/BraceMatchingService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type internal FSharpBraceMatchingService() =
static member GetBraceMatchingResult(sourceText, fileName, options, position) = async {
let isPositionInRange(range) =
let span = CommonRoslynHelpers.FSharpRangeToTextSpan(sourceText, range)
span.Start <= position && position <= span.End
span.Start <= position && position < span.End
let! matchedBraces = FSharpChecker.Instance.MatchBracesAlternate(fileName, sourceText.ToString(), options)

return matchedBraces |> Seq.tryFind(fun(left, right) -> isPositionInRange(left) || isPositionInRange(right))
Expand Down
15 changes: 14 additions & 1 deletion vsintegration/tests/unittests/BraceMatchingServiceTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,17 @@ type BraceMatchingServiceTests() =
let x = \"stringValue\" + (endsInString +
\" )endsInString <startsInString \" +
+ >startsInString"
this.VerifyNoBraceMatch(code, startMarker)
this.VerifyNoBraceMatch(code, startMarker)

[<Test>]
member this.BraceMatchingAtEndOfLine_Bug1597() =
// https://github.com/Microsoft/visualfsharp/issues/1597
let code = """
[<EntryPoint>]
let main argv =
let arg1 = ""
let arg2 = ""
let arg3 = ""
(printfn "%A '%A' '%A'" (arg1) (arg2) (arg3))endBrace
0 // return an integer exit code"""
this.VerifyBraceMatch(code, "(printfn", ")endBrace")

0 comments on commit 749ba2d

Please sign in to comment.