Skip to content
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

F5 on a saved script isn't dot sourcing #3715

Closed
5 tasks done
SeeminglyScience opened this issue Dec 9, 2021 · 7 comments · Fixed by PowerShell/PowerShellEditorServices#1652
Closed
5 tasks done
Assignees
Labels
Bug: Pre-release Bugs reproducing only in the pre-release extension. Issue-Bug A bug to squash.

Comments

@SeeminglyScience
Copy link
Collaborator

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

Looks like we're creating a new scope for invocation of script files, leaving any set variables and functions no longer accessible.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.10
PSEdition                      Core
GitCommitId                    7.2.0-preview.10
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.60.0
e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
x64

Extension Version

ms-vscode.powershell-preview@2021.11.1

Steps to Reproduce

  1. New file
  2. Add $a = 50
  3. Save it
  4. F5
  5. Type $a in the PSIC
  6. See it's not set

Visuals

No response

Logs

No response

@SeeminglyScience SeeminglyScience added the Issue-Bug A bug to squash. label Dec 9, 2021
@ghost ghost added the Needs: Triage Maintainer attention needed! label Dec 9, 2021
@JustinGrote
Copy link
Collaborator

I feel like I called this out earlier that it was using & instead of . in the code.

@SeeminglyScience
Copy link
Collaborator Author

Totally possible. I felt like I had seen it before but couldn't quickly find anything

@andyleejordan
Copy link
Member

@rjmholt Do you remember why you changed from dot-source to ampersand-execute?

@andyleejordan
Copy link
Member

Feels to me like something we should change back just for consistency among user expectations.

@rjmholt
Copy link
Contributor

rjmholt commented Dec 9, 2021

Probably an oversight. Moving away from dot-sourcing in the API is done for constrained language mode compatibility. In this case (if I've read correctly) that doesn't make sense because the debugger isn't going to work in CLM. Just remember that anything that dot-sources or uses useLocalScope: false (the default setting) will fail in CLM.

@Harryki
Copy link

Harryki commented Jan 30, 2024

Just wanna thank you for opening this issue. I've been searching "how to auto dot source when save file" and taught me F5 does dot source current file

@JustinGrote
Copy link
Collaborator

@Harryki just to clarify, F5 runs the default debug configuration, which typically is run current PS file by default.
image

If you set the debug config to something else (like interactive mode or attach), it will always do that until you switch it again. Just an FYI to anyone else coming here who isn't sure why it isn't working for them, make sure your debug dropdown has run current file selected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Pre-release Bugs reproducing only in the pre-release extension. Issue-Bug A bug to squash.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants