@@ -55,7 +55,11 @@ type internal FSharpCodeLensService
5555
5656override __.VisitTypeAbbrev ( _ , range ) = Some range
5757
58- override __.VisitLetOrUse ( binding , range ) = Some range
58+ override __.VisitLetOrUse ( binding , range ) =
59+ match binding|> Seq.tryFind( fun b -> b.RangeOfHeadPat.StartLine= pos.Line) with
60+ | Some entry->
61+ Some entry.RangeOfBindingAndRhs
62+ | _ -> Some range// This can be invalid and should not happen
5963
6064override __.VisitBinding ( fn , binding ) =
6165 Some binding.RangeOfBindingAndRhs
@@ -81,7 +85,6 @@ type internal FSharpCodeLensService
8185let! res = lens.TaggedText
8286match reswith
8387| Some( taggedText, navigation) ->
84- logInfof" Tagged text%A " taggedText
8588let textBlock = new TextBlock( Background= Brushes.AliceBlue, Opacity= 0.0 , TextTrimming= TextTrimming.None)
8689 DependencyObjectExtensions.SetDefaultTextProperties( textBlock, formatMap.Value)
8790
@@ -133,14 +136,11 @@ type internal FSharpCodeLensService
133136let executeCodeLenseAsync () =
134137asyncMaybe {
135138do ! Async.Sleep800 |> liftAsync
136- logInfof" Rechecking code due to buffer edit!"
137139let! document = workspace.CurrentSolution.GetDocument( documentId.Value) |> Option.ofObj
138140let! _ , options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject( document)
139141let! _ , parsedInput , checkFileResults = checker.ParseAndCheckDocument( document, options, true , " LineLens" )
140- logInfof" Getting uses of all symbols!"
141142let! symbolUses = checkFileResults.GetAllUsesOfAllSymbolsInFile() |> liftAsync
142143let textSnapshot = buffer.CurrentSnapshot
143- logInfof" Updating due to buffer edit!"
144144
145145// Clear existing data and cache flags
146146// The results which are left.
@@ -159,25 +159,19 @@ type internal FSharpCodeLensService
159159let textSnapshot = buffer.CurrentSnapshot
160160let lineNumber = Line.toZ func.DeclarationLocation.StartLine
161161if ( lineNumber>= 0 || lineNumber< textSnapshot.LineCount) then
162- match func.FullTypeSafewith
163- | Some_ ->
164- let! displayEnv = checkFileResults.GetDisplayEnvForPos func.DeclarationLocation.Start
165-
166- let displayContext =
167- match displayEnvwith
168- | Some denv-> FSharpDisplayContext( fun _ -> denv)
169- | None-> displayContext
170-
171- let typeLayout = func.FormatLayout displayContext
172- let taggedText = ResizeArray()
162+ let! displayEnv = checkFileResults.GetDisplayEnvForPos func.DeclarationLocation.Start
163+ let displayContext =
164+ match displayEnvwith
165+ | Some denv-> FSharpDisplayContext( fun _ -> denv)
166+ | None-> displayContext
167+
168+ let typeLayout = func.FormatLayout displayContext
169+ let taggedText = ResizeArray()
173170
174- Layout.renderL( Layout.taggedTextListR taggedText.Add) typeLayout|> ignore
175- let navigation = QuickInfoNavigation( serviceProvider, checker, projectInfoManager, document, realPosition)
176- // Because the data is available notify that this line should be updated, displaying the results
177- return Some( taggedText, navigation)
178- | None->
179- logWarningf" Couldn't acquire CodeLens data for function%A " func
180- return None
171+ Layout.renderL( Layout.taggedTextListR taggedText.Add) typeLayout|> ignore
172+ let navigation = QuickInfoNavigation( serviceProvider, checker, projectInfoManager, document, realPosition)
173+ // Because the data is available notify that this line should be updated, displaying the results
174+ return Some( taggedText, navigation)
181175else return None
182176with e->
183177 logErrorf" Error in lazy line lens computation.%A " e
@@ -188,13 +182,13 @@ type internal FSharpCodeLensService
188182if newResults.ContainsKey fullDeclarationTextthen
189183 logWarningf" New results already contains:%A " fullDeclarationText
190184 newResults.[ fullDeclarationText] <- value
191-
192185for symbolUsein symbolUsesdo
193186if symbolUse.IsFromDefinitionthen
194187match symbolUse.Symbolwith
195188| :? FSharpMemberOrFunctionOrValueas funcwhen func.IsModuleValueOrMember|| func.IsProperty->
196- let funcID = func.FullName
197- let fullDeclarationText = funcID
189+ let funcID = func.LogicalName+ ( func.FullType.ToString() |> hash|> string)
190+ // Use a combination of the the function name + the hashed value of the type signature
191+ let fullDeclarationText = funcID// (textSnapshot.GetText declarationSpan).Replace(func.CompiledName, funcID)
198192let fullTypeSignature = func.FullType.ToString()
199193// Try to re-use the last results
200194if lastResults.ContainsKey fullDeclarationTextthen
@@ -297,7 +291,6 @@ type internal FSharpCodeLensService
297291let! res = createTextBox codeLens
298292if resthen
299293do ! Async.SwitchToContext uiContext
300- logInfof" Adding ui element for%A " ( codeLens.TaggedText)
301294let uiElement = codeLens.UiElement
302295let animation =
303296 DoubleAnimation(
@@ -334,7 +327,6 @@ type internal FSharpCodeLensService
334327for valuein codeLensToAdddo
335328let trackingSpan , codeLens = value
336329let Grid = lineLens.AddCodeLens trackingSpan
337- logInfof" Trackingspan%A is being added." trackingSpan
338330
339331 Grid.IsVisibleChanged
340332|> Event.filter( fun eventArgs -> eventArgs.NewValue:?> bool)
@@ -344,8 +336,6 @@ type internal FSharpCodeLensService
344336let trackingSpan , _ = oldResult.Value
345337// logInfof "removing trackingSpan %A" trackingSpan
346338 lineLens.RemoveCodeLens trackingSpan|> ignore
347-
348- logInfof" Finished updating line lens."
349339
350340if not firstTimeCheckedthen
351341 firstTimeChecked<- true
@@ -370,5 +360,4 @@ type internal FSharpCodeLensService
370360 bufferChangedCts.Cancel() // Stop all ongoing async workflow.
371361 bufferChangedCts.Dispose()
372362 bufferChangedCts<- new CancellationTokenSource()
373- executeCodeLenseAsync() |> Async.Ignore|> RoslynHelpers.StartAsyncSafe bufferChangedCts.Token" Buffer Changed"
374-
363+ executeCodeLenseAsync() |> Async.Ignore|> RoslynHelpers.StartAsyncSafe bufferChangedCts.Token" Buffer Changed"