-
Notifications
You must be signed in to change notification settings - Fork 498
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
Treat dot sourced files as links #5046
Comments
Thanks for the submission! This may be doable, the tricky part is identifying a PowerShell file path in all potential contexts, and supporting both Linux and Windows paths. I don't think PowerShell itself has an API for determining a "file path" symbol, but it certainly might be possible. Marking this as "Up for Grabs", I'd be willing to review an attempted PR, but it would need to be pretty explicit and have very few if no edge cases otherwise it could lead to very frustrating behavior of some links clickable and others not. |
Do other extensions do this? If so we should look at their implementation. |
I've only ever seen it in the logs, doing simple pattern matching. |
I am not familiar with VS Code development, but I would expect that the task of identifying a dot sourced file name would be a simple pattern (a line-starting dot+whitespace followed by a coherent string). In terms of resolving the file I would hope that PowerShell's own "Resolve-Path" might be an option (as far as I know it is also available on Linux). |
@JensGJ everything seems simple till you get down to the nitty gritty of it :) For instance, what about this: Or for a relative path, how do we know what the root path is unless $PSScriptRoot is specified? We have no way of knowing what context it is being dot sourced from or what the local terminal relative path is. For the simple scenarios like We can probably introduce initial limited support, but it's not going to be on my personal to-do anytime soon which is why I flagged it up-for-grabs. |
Related: microsoft/vscode#108527 |
There is also the option to use macros via extensions if you are looking for a solution meanwhile. By the way, was this available via ISE ? |
Prerequisites
Summary
I would like to have an easy way of opening a dot sourced file when I edit a powershell file. If I edit a ps1 file with a line like this:
. C:\powershell\myimport.ps1
I would expect that VS Code would provide me with a simple way of opening the file. It would be nice if both relative and absolute paths were supported
Proposed Design
It could be handled as a link - like the autogenerated links that are created if you write a URL anywhere in an editor window. Or it could be handled by expanding "Go to definition" to handle dot sourced files by opening them. Or just an extra option when right clicking a dot source line.
The text was updated successfully, but these errors were encountered: