Skip to content

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

Closed

Description

@kaylaerdmann

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?

Activity

  1. added this to the 0.1.0 milestone on Aug 13, 2015
  2. daviwil commented on Nov 16, 2015

    @daviwil
    Contributor

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

  3. changed the title [-]Should definition support work on dot sourced files?[/-] [+]Add go to definition support for dot sourced file paths[/+] on Nov 16, 2015
  4. modified the milestones: 0.3.0, on Dec 31, 2015
  5. dee-see commented on Dec 31, 2017

    @dee-see
    Contributor

    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?

  6. TylerLeonhardt commented on Jan 1, 2018

    @TylerLeonhardt
    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).

  7. TylerLeonhardt commented on Jan 1, 2018

    @TylerLeonhardt
    Member

    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!

  8. rkeithhill commented on Jan 1, 2018

    @rkeithhill
    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.

  9. dee-see commented on Jan 1, 2018

    @dee-see
    Contributor

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

  10. added a commit that references this issue on Dec 3, 2018
    99f01ef
  11. added a commit that references this issue on Feb 26, 2019
  12. added a commit that references this issue on Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions