@@ -46,65 +46,63 @@ type internal FSharpHelpContextService
4646 content= " ." -> true
4747| _ -> false
4848
49- let keyword =
50- let tokenInformation , col =
51- let col =
52- if caretColumn= lineText.Length&& caretColumn> 0 then
53- // if we are at the end of the line, we always step back one character
54- caretColumn- 1
55- else
56- caretColumn
49+ let tokenInformation , col =
50+ let col =
51+ if caretColumn= lineText.Length&& caretColumn> 0 then
52+ // if we are at the end of the line, we always step back one character
53+ caretColumn- 1
54+ else
55+ caretColumn
5756
58- let getTokenAt line col =
59- if col< 0 || line< 0 then Noneelse
60- let start = textLines.[ line]. Start+ col
61- let span = TextSpan.FromBounds( start, start+ 1 )
62- tokens
63- |> Seq.tryFindIndex( fun t -> t.TextSpan.Contains( span))
64- |> Option.map( fun i -> tokens.[ i])
57+ let getTokenAt line col =
58+ if col< 0 || line< 0 then Noneelse
59+ let start = textLines.[ line]. Start+ col
60+ let span = TextSpan.FromBounds( start, start+ 1 )
61+ tokens
62+ |> Seq.tryFindIndex( fun t -> t.TextSpan.Contains( span))
63+ |> Option.map( fun i -> tokens.[ i])
6564
66- match getTokenAt line colwith
67- | Some tas original-> // when col > 0 && shouldTryToFindSurroundingIdent t ->
68- if shouldTryToFindSurroundingIdent tthen
69- match getTokenAt line( col- 1 ) with
70- | Some tas newInfowhen not ( shouldTryToFindSurroundingIdent t) -> newInfo, col- 1
71- | _ ->
65+ match getTokenAt line colwith
66+ | Some tas original-> // when col > 0 && shouldTryToFindSurroundingIdent t ->
67+ if shouldTryToFindSurroundingIdent tthen
68+ match getTokenAt line( col- 1 ) with
69+ | Some tas newInfowhen not ( shouldTryToFindSurroundingIdent t) -> newInfo, col- 1
70+ | _ ->
7271match getTokenAt line( col+ 1 ) with
7372| Some tas newInfowhen not ( shouldTryToFindSurroundingIdent t) -> newInfo, col+ 1
7473| _ -> original, col
75- else original, col
76- | otherwise-> otherwise, col
74+ else original, col
75+ | otherwise-> otherwise, col
7776
78- match tokenInformationwith
79- | None-> None
80- | Some token->
81- match token.ClassificationTypewith
82- | ClassificationTypeNames.Keyword
83- | ClassificationTypeNames.Operator
84- | ClassificationTypeNames.PreprocessorKeyword->
85- sourceText.GetSubText( token.TextSpan). ToString() + " _FS" |> Some
86- | ClassificationTypeNames.Comment-> Some" comment_FS"
87- | ClassificationTypeNames.Identifier->
88- try
89- let possibleIdentifier = QuickParse.GetCompleteIdentifierIslandfalse lineText col
90- match possibleIdentifierwith
91- | None-> None
92- | Some( s, colAtEndOfNames, _) ->
93- if check.HasFullTypeCheckInfothen
94- let qualId = PrettyNaming.GetLongNameFromString s
95- check.GetF1KeywordAlternate( Line.fromZ line, colAtEndOfNames, lineText, qualId)
96- |> Async.RunSynchronously
97- else None
98- with e->
99- Assert.Exception( e)
100- reraise()
101- | _ -> None
102- return keyword
77+ match tokenInformationwith
78+ | None-> return None
79+ | Some token->
80+ match token.ClassificationTypewith
81+ | ClassificationTypeNames.Keyword
82+ | ClassificationTypeNames.Operator
83+ | ClassificationTypeNames.PreprocessorKeyword->
84+ return Some( sourceText.GetSubText( token.TextSpan). ToString() + " _FS" )
85+ | ClassificationTypeNames.Comment-> return Some" comment_FS"
86+ | ClassificationTypeNames.Identifier->
87+ try
88+ let possibleIdentifier = QuickParse.GetCompleteIdentifierIslandfalse lineText col
89+ match possibleIdentifierwith
90+ | None-> return None
91+ | Some( s, colAtEndOfNames, _) ->
92+ if check.HasFullTypeCheckInfothen
93+ let qualId = PrettyNaming.GetLongNameFromString s
94+ return ! check.GetF1KeywordAlternate( Line.fromZ line, colAtEndOfNames, lineText, qualId)
95+ else
96+ return None
97+ with e->
98+ Assert.Exception e
99+ return None
100+ | _ -> return None
103101}
104102
105103interface IHelpContextServicewith
106- member this.Language with get () = " fsharp"
107- member this.Product with get () = " fsharp"
104+ member this.Language = " fsharp"
105+ member this.Product = " fsharp"
108106
109107member this.GetHelpTermAsync ( document , textSpan , cancellationToken ) =
110108async {
@@ -116,11 +114,8 @@ type internal FSharpHelpContextService
116114let textLine = sourceText.Lines.GetLineFromPosition( textSpan.Start)
117115let tokens = CommonHelpers.getColorizationData( document.Id, sourceText, textLine.Span, Some document.Name, defines, cancellationToken)
118116let! keyword = FSharpHelpContextService.GetHelpTerm( checkerProvider.Checker, sourceText, document.FilePath, options, textSpan, tokens, textVersion.GetHashCode())
119-
120- return match keywordwith
121- | Some k-> k
122- | None-> " "
123- | None-> return " "
117+ return defaultArg keyword String.Empty
118+ | None-> return String.Empty
124119} |> CommonRoslynHelpers.StartAsyncAsTask cancellationToken
125120
126121member this.FormatSymbol ( _symbol ) = Unchecked.defaultof<_>