Closed andyleejordan closed 1 year ago
Also quoting a great example from @fflaten in https://github.com/PowerShell/vscode-powershell/issues/1465#issuecomment-1421446054:
I believe that would make the inner assignment the definition in the example below.
Function abc { $myvar = 'inner' } $myvar = 'outer'
Maybe track the first assignment per parent (when that is tracked)?
He's absolutely right that's going to happen, but we can't improve it until we have parent/child relationship tracking (and even then it might prove tricky).
I think the most annoying bit will be that for a commonly re-used symbol name like $i
, if you jump to definition on a local use of it, instead of showing you all the potential definitions, it'll just take you to the very first one.
That one has me thinking that maybe we should just filter for outline view?
Edit: I don't think that'll gain much and will be a lot trickier.
Just want to put it on record that we know this will miss a lot of stuff in large files, but that we think it'll be better to do that than to list every single assignment.
This 👍. Before this PR, open ex. Pester.psm1
and get overwhelmed by variables in outline and go to symbol.
That one has me thinking that maybe we should just filter for outline view?
Yes. I could see a value in listing all possible definitions, but outline and symbol search get easily crowded.
Something to revisit later :-)
As noted by @fflaten in https://github.com/PowerShell/vscode-powershell/issues/1465#issuecomment-1421401557, our initial logic counted every assignment as a declaration. While there's no true way to determine which is really the declaration, we can make a relatively safe assumption that the first encountered declaration is it. This is efficient, easy, and seems to work quite well.