提交 ff6aec7a 编写于 作者: S Steffen Forkmann 提交者: Kevin Ransom (msft)

Better breakpoint support when clicking (#2815)

* Better breakpoint support when clicking - fixes #2814

* Do not break on empty lines

* No need to parse if we are standing on empty lines
上级 304bf37c
......@@ -351,12 +351,24 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
(fun () ->
let locations = findBreakPoints()
match locations |> List.filter (fun m -> rangeContainsPos m pos) with
| [] ->
match locations |> List.filter (fun m -> rangeBeforePos m pos |> not) with
| [] -> Seq.tryHead locations
| locationsAfterPos -> Seq.tryHead locationsAfterPos
| coveringLocations -> Seq.tryLast coveringLocations)
if pos.Column = 0 then
// we have a breakpoint that was set with mouse at line start
match locations |> List.filter (fun m -> m.StartLine = m.EndLine && pos.Line = m.StartLine) with
| [] ->
match locations |> List.filter (fun m -> rangeContainsPos m pos) with
| [] ->
match locations |> List.filter (fun m -> rangeBeforePos m pos |> not) with
| [] -> Seq.tryHead locations
| locationsAfterPos -> Seq.tryHead locationsAfterPos
| coveringLocations -> Seq.tryLast coveringLocations
| locationsOnSameLine -> Seq.tryHead locationsOnSameLine
else
match locations |> List.filter (fun m -> rangeContainsPos m pos) with
| [] ->
match locations |> List.filter (fun m -> rangeBeforePos m pos |> not) with
| [] -> Seq.tryHead locations
| locationsAfterPos -> Seq.tryHead locationsAfterPos
| coveringLocations -> Seq.tryLast coveringLocations)
(fun _msg -> None)
/// When these files appear or disappear the configuration for the current project is invalidated.
......
......@@ -2,6 +2,7 @@
namespace Microsoft.VisualStudio.FSharp.Editor
open System
open System.Composition
open System.Collections.Generic
open System.Threading
......@@ -32,11 +33,16 @@ type internal FSharpBreakpointResolutionService
// cross-project checking in multi-project solutions). FCS will not respond to other
// requests unless this task is cancelled. We need to check that this task is cancelled in a timely way by the
// Roslyn UI machinery.
let! parseResults = checker.ParseFileInProject(fileName, sourceText.ToString(), options)
let textLinePos = sourceText.Lines.GetLinePosition(textSpan.Start)
let textLineColumn = textLinePos.Character
let fcsTextLineNumber = Line.fromZ textLinePos.Line // Roslyn line numbers are zero-based, FSharp.Compiler.Service line numbers are 1-based
return parseResults.ValidateBreakpointLocation(mkPos fcsTextLineNumber textLineColumn)
let textInLine = sourceText.GetSubText(sourceText.Lines.[textLinePos.Line].Span).ToString()
if String.IsNullOrWhiteSpace textInLine then
return None
else
let textLineColumn = textLinePos.Character
let fcsTextLineNumber = Line.fromZ textLinePos.Line // Roslyn line numbers are zero-based, FSharp.Compiler.Service line numbers are 1-based
let! parseResults = checker.ParseFileInProject(fileName, sourceText.ToString(), options)
return parseResults.ValidateBreakpointLocation(mkPos fcsTextLineNumber textLineColumn)
}
interface IBreakpointResolutionService with
......@@ -50,6 +56,6 @@ type internal FSharpBreakpointResolutionService
|> Async.map Option.toObj
|> RoslynHelpers.StartAsyncAsTask cancellationToken
// FSROSLYNTODO: enable placing breakpoints by when user suplies fully-qualified function names
// FSROSLYNTODO: enable placing breakpoints by when user supplies fully-qualified function names
member this.ResolveBreakpointsAsync(_, _, _): Task<IEnumerable<BreakpointResolutionResult>> =
Task.FromResult(Enumerable.Empty<BreakpointResolutionResult>())
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册