Skip to content

Update sort_plugin_lists.ps1#1036

Merged
chcg merged 1 commit intonotepad-plus-plus:masterfrom
MrBach69:master
Feb 11, 2026
Merged

Update sort_plugin_lists.ps1#1036
chcg merged 1 commit intonotepad-plus-plus:masterfrom
MrBach69:master

Conversation

@MrBach69
Copy link
Copy Markdown
Contributor

Pull Request: Fix sort_plugin_lists.ps1 script

Summary
Fix ConvertTo-Json depth issue that would corrupt plugin data when running the sort script.
The current script uses ConvertTo-Json without specifying -Depth. PowerShell defaults to depth 2, but the plugin objects in the JSON files are at depth 3. This causes plugin properties to be truncated to type names like System.Object[] instead of their actual values.
Changes

  1. Added -Depth 10 to ConvertTo-Json to preserve all nested data
  2. Added -Raw to Get-Content for more reliable JSON parsing
  3. Removed redundant file write operation (was writing twice)

Before::

$a = Get-Content $file | ConvertFrom-Json
$a.'npp-plugins' = $a.'npp-plugins' | sort -Property 'display-name'
$a | ConvertTo-Json > $file
$content = [IO.File]::ReadAllText($file)
$content = $content -replace ' {2}', "`t"
[IO.File]::WriteAllText($file, $content)

After

$a = Get-Content $file -Raw | ConvertFrom-Json
$a.'npp-plugins' = $a.'npp-plugins' | Sort-Object -Property 'display-name'
$content = $a | ConvertTo-Json -Depth 10
$content = $content -replace ' {2}', "`t"
[IO.File]::WriteAllText($file, $content)

--Testing--
Verified that the JSON structure (max depth 4) is fully preserved after sorting.

@chcg
Copy link
Copy Markdown
Contributor

chcg commented Jan 29, 2026

@MrBach69 I don't observe that with Powershell 7.5.4. With which version of the Powershell did it happen in your case or did you us Windows Powershell ?

@chcg chcg added the enhancement New feature or request label Feb 11, 2026
@chcg chcg merged commit f132d08 into notepad-plus-plus:master Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants