Skip to content

Commit

Permalink
Merge pull request #47 from abgox/dev
Browse files Browse the repository at this point in the history
fix(module): update version to 5.1.1
  • Loading branch information
abgox authored Nov 22, 2024
2 parents 383aaa9 + cf29372 commit 74e2a53
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 16 deletions.
5 changes: 5 additions & 0 deletions module/CHANGELOG-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<a href="./CHANGELOG-CN.md">简体中文</a>
</p>

## 5.1.1 (2024/11/22)

- 修复了 `order.json` 解析压缩导致补全报错的问题。
- 其他的优化和修复。

## 5.1.0 (2024/11/21)

- 添加方法 `$PSCompletions.argc_completions()` 用于 [argc-completions](https://github.com/sigoden/argc-completions)
Expand Down
15 changes: 15 additions & 0 deletions module/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
[
{
"version": "5.1.1",
"info": {
"zh-CN": [
"更新(2024/11/22)\n",
"- 修复了 order.json 解析压缩导致补全报错的问题。\n",
"- 其他的优化和修复。\n"
],
"en-US": [
"Update(2024/11/22)\n",
"- Fix the issue of order.json parsing compression causing completion errors.\n",
"- Other optimizations and fixes.\n"
]
}
},
{
"version": "5.1.0",
"info": {
Expand Down
5 changes: 5 additions & 0 deletions module/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<a href="./CHANGELOG.md">English</a>
</p>

## 5.1.1 (2024/11/22)

- Fix the issue of `order.json` parsing compression causing completion errors.
- Other optimizations and fixes.

## 5.1.0 (2024/11/21)

- Add method `$PSCompletions.argc_completions()` for [argc-completions](https://github.com/sigoden/argc-completions).
Expand Down
5 changes: 2 additions & 3 deletions module/PSCompletions/PSCompletions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{
RootModule = 'PSCompletions.psm1'

ModuleVersion = '5.1.0'
ModuleVersion = '5.1.1'

GUID = '00929632-527d-4dab-a5b3-21197faccd05'

Expand All @@ -21,8 +21,7 @@

CompatiblePSEditions = @('Core', 'Desktop')

Description = 'A completion manager for better and simpler use PowerShell completions.
It provides a better GUI-style tab-completion menu to enhance the command line experience.
Description = 'A completion manager for better and simpler use PowerShell completions. It provides a better GUI-style tab-completion menu to enhance the command line experience.
For more information, please visit the project or website:
- Website: https://pscompletions.pages.dev
- Github: https://github.com/abgox/PSCompletions
Expand Down
32 changes: 28 additions & 4 deletions module/PSCompletions/core/init.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using namespace System.Management.Automation
$_ = Split-Path $PSScriptRoot -Parent
New-Variable -Name PSCompletions -Value @{
version = '5.1.0'
version = '5.1.1'
path = @{
root = $_
completions = Join-Path $_ 'completions'
Expand Down Expand Up @@ -551,7 +551,12 @@ Add-Member -InputObject $PSCompletions -MemberType ScriptMethod get_completion {
}
else {
if (Test-Path $path_order) {
$PSCompletions.order.$root = $PSCompletions.ConvertFrom_JsonToHashtable($PSCompletions.get_raw_content($path_order))
try {
$PSCompletions.order.$root = $PSCompletions.ConvertFrom_JsonToHashtable($PSCompletions.get_raw_content($path_order))
}
catch {
$PSCompletions.order.$root = $null
}
}
else {
$PSCompletions.order.$root = $null
Expand Down Expand Up @@ -929,22 +934,41 @@ Add-Member -InputObject $PSCompletions -MemberType ScriptMethod add_completion {
$PSCompletions.data.alias.$completion = @()
}

$PSCompletions._alias_conflict = $false
$conflict_alias_list = @()
if ($config.alias) {
foreach ($a in $config.alias) {
if ($a -notin $PSCompletions.data.alias.$completion) {
$PSCompletions.data.alias.$completion += $a
$PSCompletions.data.aliasMap.$a = $completion
if ($PSCompletions.data.aliasMap.$a) {
$PSCompletions._alias_conflict = $true
$conflict_alias_list += $a
}
else {
$PSCompletions.data.aliasMap.$a = $completion
}
$PSCompletions._need_update_data = $true
}
}
}
else {
if ($completion -notin $PSCompletions.data.alias.$completion) {
$PSCompletions.data.alias.$completion += $completion
$PSCompletions.data.aliasMap.$completion = $completion
if ($PSCompletions.data.aliasMap.$completion) {
$PSCompletions._alias_conflict = $true
$conflict_alias_list += $completion
}
else {
$PSCompletions.data.aliasMap.$completion = $completion
}
$PSCompletions._need_update_data = $true
}
}

if ($PSCompletions._alias_conflict) {
$PSCompletions.write_with_color($PSCompletions.replace_content($PSCompletions.info.err.alias_conflict))
}

$language = $PSCompletions.get_language($completion)
$json = $PSCompletions.ConvertFrom_JsonToHashtable($PSCompletions.get_raw_content("$completion_dir/language/$language.json"))
if (!$PSCompletions.completions) {
Expand Down
12 changes: 8 additions & 4 deletions module/PSCompletions/core/utils/Core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,16 @@ Add-Member -InputObject $PSCompletions -MemberType ScriptMethod order_job {
}
}
$json = $order | ConvertTo-Json -Depth 100 -Compress
$old_json = Get-Content -Path $path_order -Raw -Encoding utf8 -ErrorAction SilentlyContinue | ConvertFrom-Json | ConvertTo-Json -Depth 100 -Compress

try {
$old_json = Get-Content -Path $path_order -Raw -Encoding utf8 -ErrorAction SilentlyContinue | ConvertFrom-Json | ConvertTo-Json -Depth 100 -Compress
}
catch {
$old_json = ''
}
if ($json -ne $old_json) {
$matches = [regex]::Matches($json, '(^"\s*"\s*:)|(\s*,"\s*"\s*:)')
$matches = [regex]::Matches($json, '[^\\]("":[-0-9]+,)')
foreach ($match in $matches) {
$json = $json -replace $match.Value, "`"empty_key_$([System.Guid]::NewGuid().Guid)`":"
$json = $json -replace $match.Groups[1].Value, ''
}
$json | Out-File $path_order -Encoding utf8 -Force
}
Expand Down
12 changes: 8 additions & 4 deletions module/PSCompletions/core/utils/Desktop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,16 @@ Add-Member -InputObject $PSCompletions -MemberType ScriptMethod order_job {
}
}
$json = $order | ConvertTo-Json -Depth 100 -Compress
$old_json = Get-Content -Path $path_order -Raw -Encoding utf8 -ErrorAction SilentlyContinue | ConvertFrom-Json | ConvertTo-Json -Depth 100 -Compress

try {
$old_json = Get-Content -Path $path_order -Raw -Encoding utf8 -ErrorAction SilentlyContinue | ConvertFrom-Json | ConvertTo-Json -Depth 100 -Compress
}
catch {
$old_json = ''
}
if ($json -ne $old_json) {
$matches = [regex]::Matches($json, '(^"\s*"\s*:)|(\s*,"\s*"\s*:)')
$matches = [regex]::Matches($json, '[^\\]("":[-0-9]+,)')
foreach ($match in $matches) {
$json = $json -replace $match.Value, "`"empty_key_$([System.Guid]::NewGuid().Guid)`":"
$json = $json -replace $match.Groups[1].Value, ''
}
$json | Out-File $path_order -Encoding utf8 -Force
}
Expand Down
2 changes: 1 addition & 1 deletion module/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.0
5.1.1

0 comments on commit 74e2a53

Please sign in to comment.