@@ -341,6 +341,18 @@ type FSharpTextEditorCompletion() =
341
341
342
342
343
343
open Microsoft.FSharp .Compiler .Range
344
+
345
+ [<AutoOpen>]
346
+ module Helper =
347
+ type UntypedParseInfo with
348
+ // GetNavigationItems is not 100% solid and throws occasional exceptions
349
+ member x.GetNavigationItemsDeclarationsSafe () =
350
+ try x.GetNavigationItems() .Declarations
351
+ with _ ->
352
+ Debug.Assert( false , " couldn't update navigation items, ignoring" )
353
+ [| |]
354
+
355
+
344
356
type FSharpPathExtension () =
345
357
inherit TextEditorExtension()
346
358
@@ -387,7 +399,10 @@ type FSharpPathExtension() =
387
399
let cursor = ( docloc.Column, docloc.Line)
388
400
posGeq cursor start && posGeq finish cursor
389
401
390
- let toplevel = ast.Untyped.GetNavigationItems() .Declarations
402
+ let toplevel =
403
+ // GetNavigationItems is not 100% solid and throws occasional exceptions
404
+ try ast.Untyped.GetNavigationItemsDeclarationsSafe()
405
+ with _ -> [| |]
391
406
392
407
#if DEBUG
393
408
let allthings = [| for tl in toplevel do yield ( tl.Declaration.Name, tl.Nested |> Array.map ( fun n -> n.Name)) |]
@@ -454,13 +469,13 @@ and FSharpDataProvider(ext:FSharpPathExtension, tag) =
454
469
memberList.Clear()
455
470
match tag with
456
471
| :? TypedParseResult as tpr ->
457
- let navitems = tpr.Untyped.GetNavigationItems ()
458
- for decl in navitems.Declarations do
472
+ let navitems = tpr.Untyped.GetNavigationItemsDeclarationsSafe ()
473
+ for decl in navitems do
459
474
memberList.Add( decl.Declaration)
460
475
| :? ( TypedParseResult * string) as typeAndFilter ->
461
476
let tpr , filter = typeAndFilter
462
- let navitems = tpr.Untyped.GetNavigationItems ()
463
- for decl in navitems.Declarations do
477
+ let navitems = tpr.Untyped.GetNavigationItemsDeclarationsSafe ()
478
+ for decl in navitems do
464
479
if decl.Declaration.Name.StartsWith( filter) then
465
480
memberList.Add( decl.Declaration)
466
481
| :? TopLevelDeclaration as tld ->
0 commit comments