@@ -65,7 +65,11 @@ type internal FSharpCodeLensService
6565match binding|> Seq.tryFind( fun b -> b.RangeOfHeadPat.StartLine= pos.Line) with
6666| Some entry->
6767 Some entry.RangeOfBindingAndRhs
68- | _ -> Some range// This can be invalid and should not happen
68+ | None->
69+ // We choose to use the default range because
70+ // it wasn't possible to find the complete range
71+ // including implementation code.
72+ Some range
6973
7074override __.VisitBinding ( fn , binding ) =
7175 Some binding.RangeOfBindingAndRhs
@@ -193,30 +197,29 @@ type internal FSharpCodeLensService
193197return None
194198}
195199
196- let inline setNewResultsAndWarnIfOverriden fullDeclarationText value=
197- if newResults.ContainsKeyfullDeclarationText then
200+ let inline setNewResultsAndWarnIfOverriden funcID value=
201+ if newResults.ContainsKeyfuncID then
198202#if DEBUG
199- logWarningf" New results already contains:%A " fullDeclarationText
203+ logWarningf" New results already contains:%A " funcID
200204#else
201205()
202206#endif
203- newResults.[ fullDeclarationText ] <- value
207+ newResults.[ funcID ] <- value
204208for symbolUsein symbolUsesdo
205209if symbolUse.IsFromDefinitionthen
206210match symbolUse.Symbolwith
207211| :? FSharpMemberOrFunctionOrValueas funcwhen func.IsModuleValueOrMember|| func.IsProperty->
208212let funcID = func.LogicalName+ ( func.FullType.ToString() |> hash|> string)
209213// Use a combination of the the function name + the hashed value of the type signature
210- let fullDeclarationText = funcID// (textSnapshot.GetText declarationSpan).Replace(func.CompiledName, funcID)
211214let fullTypeSignature = func.FullType.ToString()
212215// Try to re-use the last results
213- if lastResults.ContainsKeyfullDeclarationText then
216+ if lastResults.ContainsKeyfuncID then
214217// Make sure that the results are usable
215- let inline setNewResultsAndWarnIfOverridenLocal value = setNewResultsAndWarnIfOverridenfullDeclarationText value
216- let lastTrackingSpan , codeLens as lastResult = lastResults.[ fullDeclarationText ]
218+ let inline setNewResultsAndWarnIfOverridenLocal value = setNewResultsAndWarnIfOverridenfuncID value
219+ let lastTrackingSpan , codeLens as lastResult = lastResults.[ funcID ]
217220if codeLens.FullTypeSignature= fullTypeSignaturethen
218221 setNewResultsAndWarnIfOverridenLocal lastResult
219- oldResults.RemovefullDeclarationText |> ignore
222+ oldResults.RemovefuncID |> ignore
220223else
221224let declarationLine , range =
222225match visit func.DeclarationLocation.Start parsedInputwith
@@ -236,19 +239,19 @@ type internal FSharpCodeLensService
236239 fullTypeSignature,
237240null )
238241// The old results aren't computed at all, because the line might have changed create new results
239- tagsToUpdate.[ lastTrackingSpan] <- ( newTrackingSpan, fullDeclarationText , res)
242+ tagsToUpdate.[ lastTrackingSpan] <- ( newTrackingSpan, funcID , res)
240243 setNewResultsAndWarnIfOverridenLocal( newTrackingSpan, res)
241244
242- oldResults.RemovefullDeclarationText |> ignore
245+ oldResults.RemovefuncID |> ignore
243246else
244247// The symbol might be completely new or has slightly changed.
245248// We need to track this and iterate over the left entries to ensure that there isn't anything
246- unattachedSymbols.Add(( symbolUse, func, fullDeclarationText , fullTypeSignature))
249+ unattachedSymbols.Add(( symbolUse, func, funcID , fullTypeSignature))
247250| _ -> ()
248251
249252// In best case this works quite `covfefe` fine because often enough we change only a small part of the file and not the complete.
250253for unattachedSymbolin unattachedSymbolsdo
251- let symbolUse , func , fullDeclarationText , fullTypeSignature = unattachedSymbol
254+ let symbolUse , func , funcID , fullTypeSignature = unattachedSymbol
252255let declarationLine , range =
253256match visit func.DeclarationLocation.Start parsedInputwith
254257| Some range-> range.StartLine- 1 , range
@@ -267,8 +270,8 @@ type internal FSharpCodeLensService
267270let newTrackingSpan =
268271 textSnapshot.CreateTrackingSpan( declarationSpan, SpanTrackingMode.EdgeExclusive)
269272if codeLens.Computed&& ( isNull codeLens.UiElement|> not ) then
270- newResults.[ fullDeclarationText ] <- ( newTrackingSpan, codeLens)
271- tagsToUpdate.[ trackingSpan] <- ( newTrackingSpan, fullDeclarationText , codeLens)
273+ newResults.[ funcID ] <- ( newTrackingSpan, codeLens)
274+ tagsToUpdate.[ trackingSpan] <- ( newTrackingSpan, funcID , codeLens)
272275else
273276let res =
274277 CodeLens(
@@ -277,8 +280,8 @@ type internal FSharpCodeLensService
277280 fullTypeSignature,
278281null )
279282// The tag might be still valid but it hasn't been computed yet so create fresh results
280- tagsToUpdate.[ trackingSpan] <- ( newTrackingSpan, fullDeclarationText , res)
281- newResults.[ fullDeclarationText ] <- ( newTrackingSpan, res)
283+ tagsToUpdate.[ trackingSpan] <- ( newTrackingSpan, funcID , res)
284+ newResults.[ funcID ] <- ( newTrackingSpan, res)
282285let key = res.Key
283286 oldResults.Remove key|> ignore// no need to check this entry again
284287| None->
@@ -299,7 +302,7 @@ type internal FSharpCodeLensService
299302let trackingSpan =
300303 textSnapshot.CreateTrackingSpan( declarationSpan, SpanTrackingMode.EdgeExclusive)
301304 codeLensToAdd.Add( trackingSpan, res)
302- newResults.[ fullDeclarationText ] <- ( trackingSpan, res)
305+ newResults.[ funcID ] <- ( trackingSpan, res)
303306#if DEBUG
304307with e->
305308 logExceptionWithContext( e, " Line Lens tracking tag span creation" )