@@ -107,11 +107,11 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
107107( fun _ -> NavigationImpl.empty)
108108
109109member private scope.ValidateBreakpointLocationImpl ( pos ) =
110+ let isMatchRange m = rangeContainsPos m pos|| m.StartLine= pos.Line
110111
111-
112112// Process let-binding
113113let findBreakPoints () =
114- let checkRange m = [ if rangeContainsPos m pos || m.StartLine = pos.Line then yield m]
114+ let checkRange m = [ if isMatchRange m then yield m]
115115let walkBindSeqPt sp = [ match spwith SequencePointAtBinding m-> yield ! checkRange m| _ -> () ]
116116let walkForSeqPt sp = [ match spwith SequencePointAtForLoop m-> yield ! checkRange m| _ -> () ]
117117let walkWhileSeqPt sp = [ match spwith SequencePointAtWhileLoop m-> yield ! checkRange m| _ -> () ]
@@ -131,22 +131,35 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
131131
132132yield ! walkExpr( isFunction|| ( match spInfowith SequencePointAtBinding_ -> false | _ -> true )) synExpr]
133133
134- and walkExprs es = [ for e in es do yield ! walkExprfalse e ]
135- and walkBinds es = [ for e in es do yield ! walkBinde ]
134+ and walkExprs es = List.collect ( walkExprfalse ) es
135+ and walkBinds es = List.collect walkBindes
136136and walkMatchClauses cl =
137137[ for ( Clause(_, whenExpr, e,_,_)) in cldo
138- match whenExprwith Some e-> yield ! walkExprfalse e| _ -> ()
138+ match whenExprwith
139+ | Some e-> yield ! walkExprfalse e
140+ | _ -> ()
139141yield ! walkExprtrue e]
140142
141143and walkExprOpt ( spAlways : bool ) eOpt = [ match eOptwith Some e-> yield ! walkExpr spAlways e| _ -> () ]
142144
145+ and IsBreakableExpression e =
146+ match ewith
147+ | SynExpr.Match_
148+ | SynExpr.IfThenElse_
149+ | SynExpr.For_
150+ | SynExpr.ForEach_
151+ | SynExpr.While_ -> true
152+ | _ -> not ( IsControlFlowExpression e)
153+
143154// Determine the breakpoint locations for an expression. spAlways indicates we always
144155// emit a breakpoint location for the expression unless it is a syntactic control flow construct
145- and walkExpr ( spAlways : bool ) e =
146- [ if spAlways&& not ( IsControlFlowExpression e) then
147- yield ! checkRange e.Range
148- match ewith
156+ and walkExpr ( spAlways : bool ) e =
157+ let m = e.Range
158+ if not ( isMatchRange m) then [] else
159+ [ if spAlways&& IsBreakableExpression ethen
160+ yield ! checkRange m
149161
162+ match ewith
150163| SynExpr.ArbitraryAfterError_
151164| SynExpr.LongIdent_
152165| SynExpr.LibraryOnlyILAssembly_
@@ -279,15 +292,17 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
279292yield ! walkExprtrue e2]
280293
281294// Process a class declaration or F# type declaration
282- let rec walkTycon ( TypeDefn ( ComponentInfo ( _ , _ , _ , _ , _ , _ , _ , _ ), repr , membDefns , _ )) =
283- [ for min membDefnsdo yield ! walkMember m
295+ let rec walkTycon ( TypeDefn ( ComponentInfo ( _ , _ , _ , _ , _ , _ , _ , _ ), repr , membDefns , m )) =
296+ if not ( isMatchRange m) then [] else
297+ [ for membin membDefnsdo yield ! walkMember memb
284298match reprwith
285299| SynTypeDefnRepr.ObjectModel(_, membDefns, _) ->
286- for m in membDefnsdo yield ! walkMemberm
300+ for memb in membDefnsdo yield ! walkMembermemb
287301| _ -> () ]
288302
289303// Returns class-members for the right dropdown
290- and walkMember memb =
304+ and walkMember memb =
305+ if not ( rangeContainsPos memb.Range pos) then [] else
291306[ match membwith
292307| SynMemberDefn.LetBindings( binds, _, _, _) -> yield ! walkBinds binds
293308| SynMemberDefn.AutoProperty(_ attribs, _ isStatic, _ id, _ tyOpt, _ propKind, _, _ xmlDoc, _ access, synExpr, _, _) -> yield ! walkExprtrue synExpr
@@ -303,36 +318,30 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
303318// (such as type declarations, nested modules etc.)
304319let rec walkDecl decl =
305320[ match declwith
306- | SynModuleDecl.Let(_, binds, m) ->
307- if rangeContainsPos m posthen
308- yield ! walkBinds binds
309- | SynModuleDecl.DoExpr( spExpr, expr, _) ->
321+ | SynModuleDecl.Let(_, binds, m) when isMatchRange m->
322+ yield ! walkBinds binds
323+ | SynModuleDecl.DoExpr( spExpr, expr, m) when isMatchRange m->
310324yield ! walkBindSeqPt spExpr
311325yield ! walkExprfalse expr
312- | SynModuleDecl.ModuleAbbrev_ ->
313- ()
314- | SynModuleDecl.NestedModule(_, _ isRec, decls, _, m) ->
315- if rangeContainsPos m posthen
316- for din declsdo yield ! walkDecl d
317- | SynModuleDecl.Types( tydefs, m) ->
318- if rangeContainsPos m posthen
319- for din tydefsdo yield ! walkTycon d
320- | SynModuleDecl.Exception( SynExceptionDefn( SynExceptionDefnRepr(_, _, _, _, _, _), membDefns, _), m) ->
321- if rangeContainsPos m posthen
322- for min membDefnsdo yield ! walkMember m
323- | _ ->
324- () ]
326+ | SynModuleDecl.ModuleAbbrev_ -> ()
327+ | SynModuleDecl.NestedModule(_, _ isRec, decls, _, m) when isMatchRange m->
328+ for din declsdo yield ! walkDecl d
329+ | SynModuleDecl.Types( tydefs, m) when isMatchRange m->
330+ for din tydefsdo yield ! walkTycon d
331+ | SynModuleDecl.Exception( SynExceptionDefn( SynExceptionDefnRepr(_, _, _, _, _, _), membDefns, _), m)
332+ when isMatchRange m->
333+ for min membDefnsdo yield ! walkMember m
334+ | _ -> () ]
325335
326- // Collect all the items
336+ // Collect all the itemsin a module
327337let walkModule ( SynModuleOrNamespace ( _ , _ , _ , decls , _ , _ , _ , m )) =
328- if rangeContainsPos mpos then
329- [ for d in decls do yield ! walkDecld ]
338+ if isMatchRange mthen
339+ List.collect walkDecldecls
330340else
331341[]
332342
333343/// Get information for implementation file
334- let walkImplFile ( modules : SynModuleOrNamespace list ) =
335- [ for xin modulesdo yield ! walkModule x]
344+ let walkImplFile ( modules : SynModuleOrNamespace list ) = List.collect walkModule modules
336345
337346match inputwith
338347| Some( ParsedInput.ImplFile( ParsedImplFileInput(_,_,_,_,_, modules,_))) -> walkImplFile modules
@@ -344,9 +353,12 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
344353let locations = findBreakPoints()
345354
346355match locations|> List.filter( fun m -> rangeContainsPos m pos) with
347- | [] -> Seq.tryHead locations
348- | locations-> Seq.tryLast locations)
349- ( fun _msg -> None)
356+ | [] ->
357+ match locations|> List.filter( fun m -> rangeBeforePos m pos|> not ) with
358+ | [] -> Seq.tryHead locations
359+ | locationsAfterPos-> Seq.tryHead locationsAfterPos
360+ | coveringLocations-> Seq.tryLast coveringLocations)
361+ ( fun _msg -> None)
350362
351363/// When these files appear or disappear the configuration for the current project is invalidated.
352364member scope.DependencyFiles = dependencyFiles