Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Restarting extensions caused npm scripts in the sidebar to appear in random order until the tree was collapsed and re-expanded.

NpmScriptsTreeDataProvider.getChildren() only sorted top-level items (folders/packages) but returned unsorted arrays for child elements. Script order depended on task provider enumeration order, which varied across extension restarts.

Changes:

  • Sort packages within folders before returning from getChildren()
  • Sort scripts within package.json nodes before returning from getChildren()

Both now use the existing sortTaskTree() method for consistent alphabetical ordering.

// Before
if (element instanceof PackageJSON) {
    return element.scripts;  // Unsorted
}

// After
if (element instanceof PackageJSON) {
    return this.sortTaskTree(element.scripts);  // Sorted
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Restarting extensions messes the script order in npm scripts pane in the folder side bar.</issue_title>
<issue_description>

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version:
    Version: 1.88.1 (Universal)
    Commit: e170252
    Date: 2024-04-10T17:42:52.765Z (1 wk ago)
    Electron: 28.2.8
    ElectronBuildId: 27744544
    Chromium: 120.0.6099.291
    Node.js: 18.18.2
    V8: 12.0.267.19-electron.0
    OS: Darwin arm64 23.4.0

  • OS Version:
    macOS Sonoma version 14.4.1

Steps to Reproduce:

  1. Open your folder in vscode.
  2. Observe there are updated extensions.
  3. After they are installed, click on one of the Restart Extensions buttons.
  4. The extensions will reload.
  5. Go back to Folders in the side-bar.
  6. Observe the order of npm scripts in the npm scripts pane scramble. See image below.
    CleanShot 2024-04-18 at 17 51 41
  7. Collapse the npm scripts pane, and re-expand it, notice this time the order is correct, see image below.
    CleanShot 2024-04-18 at 17 52 25

</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Sort packages and scripts in getChildren to ensure consistent ordering
regardless of when the tree view is expanded. Previously only the top-level
tree was sorted, causing scripts to appear in random order after extension
restart until the tree was collapsed and re-expanded.

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix script order issue in npm scripts pane Fix npm scripts order scrambling after extension restart Dec 8, 2025
Copilot AI requested a review from alexr00 December 8, 2025 11:32
Copilot finished work on behalf of alexr00 December 8, 2025 11:32
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.

Restarting extensions messes the script order in npm scripts pane in the folder side bar.

2 participants