Fix "Create New" script to open the script file after creation#499
Merged
eleanorjboyd merged 5 commits intomainfrom Jun 11, 2025
Merged
Fix "Create New" script to open the script file after creation#499eleanorjboyd merged 5 commits intomainfrom
eleanorjboyd merged 5 commits intomainfrom
Conversation
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] "Create New" script should open the script
Fix "Create New" script to open the script file after creation
Jun 5, 2025
amunger
approved these changes
Jun 10, 2025
karthiknadig
approved these changes
Jun 11, 2025
NguyenCuong1989
referenced
this pull request
in NguyenCuong1989/vscode-python-environments
Oct 23, 2025
When using the "Create New" functionality to create a Python script, the script file was being created successfully but not opened in the editor, requiring users to manually navigate and open the file. This PR fixes the issue by modifying the `addPythonProjectCommand` function to: 1. Capture the return value from `creator.create()` 2. Check if the result is a `Uri` (indicating a single file like a script was created) 3. Call `showTextDocument(uri)` to automatically open the script in the editor **Before:** - User selects "Create New" → Script → enters name - Script file is created but user has to manually find and open it **After:** - User selects "Create New" → Script → enters name - Script file is created AND automatically opened in the editor The implementation is minimal and surgical: - Only affects cases where creators return a `Uri` (like script files) - Projects that return `PythonProject` objects are unaffected - Uses existing `showTextDocument` utility function - Applied to both the main creator path and existing projects creator path Fixes #478. --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using the "Create New" functionality to create a Python script, the script file was being created successfully but not opened in the editor, requiring users to manually navigate and open the file.
This PR fixes the issue by modifying the
addPythonProjectCommandfunction to:creator.create()Uri(indicating a single file like a script was created)showTextDocument(uri)to automatically open the script in the editorBefore:
After:
The implementation is minimal and surgical:
Uri(like script files)PythonProjectobjects are unaffectedshowTextDocumentutility functionFixes #478.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.