Skip to content

VSCode Peek / Go to Definition functions do not work when variable is cast as specific type #1439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stukey opened this issue Jul 17, 2018 · 9 comments · Fixed by PowerShell/PowerShellEditorServices#706
Assignees
Labels

Comments

@stukey
Copy link

stukey commented Jul 17, 2018

System Details

  • Operating system name and version: Windows 10
  • VS Code version: 1.25.1
  • PowerShell extension version: 1.8.1
  • Output from $PSVersionTable: see below
S C:\Users\me> code -v
1.25.1
1dfc5e557209371715f655691b1235b6b26a06be
x64
PS C:\Users\me> $psEditor.EditorServicesVersion
 
Major  Minor  Build  Revision
-----  -----  -----  --------
1      8      1      0
 
PS C:\Users\me> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
 
PS C:\Users\me> $psversiontable
 
Name                           Value
----                           -----
PSVersion                      5.1.14393.2248
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.2248
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am not sure whether this is a VSCode issue or a PowerShell Extension issue so please forgive me if I have logged this in the wrong place.

In the latest version of VSCode (1.25.1) with the latest version of the PowerShell Extension (1.8.1) on Windows 10:

If you cast your variables by prefixing them with the type, e.g. [string], the “Go to Definition” and “Peak Definition” functions do not work.

Example:
 
[string]$testVar = "Test123"
 
$testVar

Right-click on the second ‘$testVar’ and select either “Go to Definition” or “Peak definition” and you’ll get an error “No definition found for $testVar”. Screenshot:

6f3ab4e0-72eb-41d7-b439-18c5670e824e

Try it without casting it as a [string] and it works as expected.

@TylerLeonhardt TylerLeonhardt self-assigned this Jul 18, 2018
@TylerLeonhardt
Copy link
Member

I have a fix for this - plus some bonus fixes :)

@stukey
Copy link
Author

stukey commented Jul 18, 2018

@tylerl0706 Great news. Thanks Tyler. Any more info on the bonus fixes 👍

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Jul 18, 2018

$var1 = "string"
$var1

[string] $var2 = "string"
$var2

[NotNull()] $var3 = "string"
$var3

$a, $var4 = "string", "sss"
$var4

$a, [string] $var5 = "string", "sss"
$var5

will all go to the correct spot.

@mklement0
Copy link
Contributor

@stukey: Just to aid in discovery of this issue, can you please correct the typo in the title (and body)? peak -> peek

@TylerLeonhardt TylerLeonhardt changed the title VSCode Peak / Go to Definition functions do not work when variable is cast as specific type VSCode Peek / Go to Definition functions do not work when variable is cast as specific type Jul 24, 2018
@stukey
Copy link
Author

stukey commented Jul 24, 2018

Sure if you can tell me how to do that. I can’t see an option to edit the title, only the body of the original post.

@stukey
Copy link
Author

stukey commented Jul 24, 2018

Ah looks like @tyler0706 already did it.

@mklement0
Copy link
Contributor

@stukey: Great; in general, look for the button labeled Edit to the right of the title:

image

@stukey
Copy link
Author

stukey commented Jul 24, 2018 via email

@TylerLeonhardt
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants