Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 5, 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 in the docs.

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
Copilot AI requested a review from eleanorjboyd June 5, 2025 15:37
Copilot finished work on behalf of eleanorjboyd June 5, 2025 15:37
@eleanorjboyd eleanorjboyd marked this pull request as ready for review June 10, 2025 20:26
@vs-code-engineering vs-code-engineering bot added this to the June 2025 milestone Jun 10, 2025
@eleanorjboyd eleanorjboyd enabled auto-merge (squash) June 10, 2025 20:39
@eleanorjboyd eleanorjboyd merged commit b8d1a91 into main Jun 11, 2025
10 checks passed
@eleanorjboyd eleanorjboyd deleted the copilot/fix-478 branch June 11, 2025 16:35
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] <[email protected]>
Co-authored-by: eleanorjboyd <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Create New" script should open the script

4 participants