Skip to content

Add go to definition support for dot sourced file paths #17

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
kaylaerdmann opened this issue Aug 13, 2015 · 6 comments · Fixed by #786
Closed

Add go to definition support for dot sourced file paths #17

kaylaerdmann opened this issue Aug 13, 2015 · 6 comments · Fixed by #786
Labels
Area-Code Navigation Issue-Enhancement A feature request (enhancement).

Comments

@kaylaerdmann
Copy link

When peek definition or go to definition are used on a dot sourced file nothing happens. This is currently the same behavior that happens on built-in commands where the source file can't be found.

Should peek and go to definition bring the user to the very beginning of the dot sourced file when those features are used?

@kaylaerdmann kaylaerdmann added this to the 0.1.0 milestone Aug 13, 2015
@daviwil daviwil added Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs. and removed question labels Nov 9, 2015
@daviwil daviwil modified the milestones: 0.2.0, 0.1.0 Nov 16, 2015
@daviwil
Copy link
Contributor

daviwil commented Nov 16, 2015

This is definitely a good idea, will add it for 0.2.

@daviwil daviwil changed the title Should definition support work on dot sourced files? Add go to definition support for dot sourced file paths Nov 16, 2015
@daviwil daviwil modified the milestones: 0.2.0, 0.3.0 Nov 20, 2015
@daviwil daviwil modified the milestones: 0.3.0, Backlog Dec 31, 2015
@dee-see
Copy link
Contributor

dee-see commented Dec 31, 2017

I'd like to start working on this. I won't be very quick, but seeing as it has been untouched for over 2 years that should not be a big problem.

I have a question about the desired behavior. It's simple if the dot sourced script is a full path, however let's assume that we have . ./SomeScript.ps1 in our file. SomeScript could be anywhere depending on the working directory or the Set-Locations that happened during execution. Should we simply try to locate the script relative to the one that's currently being edited as a "best guess" and move on if it isn't there?

@TylerLeonhardt
Copy link
Member

I think that's the correct approach.

There will be some scenarios where we will be unable to find the file like in this example:
. "$myComplexPath/SomeScript.ps1"

If myComplexPath is not set correctly at the time of "go to definition", we have no choice but to fail gracefully (aka do nothing).

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Jan 1, 2018

So full paths and paths that resolve correctly from the current location PSES is at is probably good enough for now - and I think a lot of folks would be happy to see this!

@rkeithhill
Copy link
Contributor

We should be able to at least handle $PSScriptRoot in a dot sourced path or this feature will be kind of worthless. 95% of the dot sourcing I do is either with $PSScriptRoot directly or a path relative to it.

@dee-see
Copy link
Contributor

dee-see commented Jan 1, 2018

Alright sounds good, thanks. I'll give it a go.

@TylerLeonhardt TylerLeonhardt added Area-Code Navigation and removed Up for Grabs Will shepherd PRs. labels Jan 17, 2018
rjmholt pushed a commit that referenced this issue Dec 3, 2018
* Implement go-to-definition for dot-sourced files

* Support $PSScriptRoot in dot-sourced files

* Add PathUtils for unified path normalization
TylerLeonhardt pushed a commit to TylerLeonhardt/PowerShellEditorServices that referenced this issue Feb 26, 2019
TylerLeonhardt pushed a commit to TylerLeonhardt/PowerShellEditorServices that referenced this issue Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Code Navigation Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants