Skip to content

Commit

Permalink
Merge pull request #57 from abgox/module
Browse files Browse the repository at this point in the history
fix(module): update version to 5.1.3
  • Loading branch information
abgox authored Nov 30, 2024
2 parents 671b7d6 + caa4086 commit 9f2b8b9
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 30 deletions.
6 changes: 6 additions & 0 deletions module/CHANGELOG-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
<a href="./CHANGELOG-CN.md">简体中文</a>
</p>

## 5.1.3 (2024/11/30)

- 修复拥有 `hooks.ps1` 的补全命令的动态补全不生效的问题。
- 当模块需要更新时,会尝试多种更新方式。
- 其他的优化和修复。

## 5.1.2 (2024/11/27)

- 由于未来的 Windows Terminal 的变化,将导致在补全菜单中无法正常显示 😄🤔😎,因此这三个默认特殊符号将改变。
Expand Down
6 changes: 6 additions & 0 deletions module/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
<a href="./CHANGELOG.md">English</a>
</p>

## 5.1.3 (2024/11/30)

- Fix the issue of dynamic completion not taking effect for commands with `hooks.ps1`.
- When a module needs to be updated, it will try multiple update methods.
- Other optimizations and fixes.

## 5.1.2 (2024/11/27)

- Due to future changes in Windows Terminal, 😄🤔😎 will not be displayed properly in the completion menu, so these three default special symbols will change.
Expand Down
2 changes: 1 addition & 1 deletion 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.2'
ModuleVersion = '5.1.3'

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

Expand Down
21 changes: 1 addition & 20 deletions module/PSCompletions/core/completion/win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
return
}

# Windows PowerShell 5.x
if ($PSEdition -ne 'Core') {
$PSCompletions.config.horizontal = '-'
$PSCompletions.config.vertical = '|'
$PSCompletions.config.top_left = '+'
$PSCompletions.config.bottom_left = '+'
$PSCompletions.config.top_right = '+'
$PSCompletions.config.bottom_right = '+'
}

# 是否是按下空格键触发的补全
$space_tab = if ($buffer[-1] -eq ' ') { 1 }else { 0 }
# 使用正则表达式进行分割,将命令行中的每个参数分割出来,形成一个数组, 引号包裹的内容会被当作一个参数,且数组会包含 "--"
Expand Down Expand Up @@ -80,7 +70,7 @@
$tool_tip = $completion.ToolTip
}
else {
# 如果是内置命令,由于其 ToolTip 写法很奇怪,会导致显示的内容有些问题
# XXX: 如果是内置命令(如: Get-Content等),其 ToolTip 写法很奇怪,会导致显示的内容有些问题,这里做了特殊处理
$tool_tip = @()
foreach ($tip in $completion.ToolTip) {
$tip = $tip -replace '\s{2}', ' '
Expand Down Expand Up @@ -150,15 +140,6 @@

$filter_list = $PSCompletions.get_completion()
if ($PSCompletions.config.enable_menu -eq 1) {
# Windows PowerShell 5.x
if ($PSEdition -ne 'Core') {
$PSCompletions.config.horizontal = '-'
$PSCompletions.config.vertical = '|'
$PSCompletions.config.top_left = '+'
$PSCompletions.config.bottom_left = '+'
$PSCompletions.config.top_right = '+'
$PSCompletions.config.bottom_right = '+'
}
$PSCompletions.menu.show_module_menu($filter_list)
}
else {
Expand Down
36 changes: 28 additions & 8 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.2'
version = '5.1.3'
path = @{
root = $_
completions = Join-Path $_ 'completions'
Expand Down Expand Up @@ -509,11 +509,9 @@ Add-Member -InputObject $PSCompletions -MemberType ScriptMethod get_completion {

$input_arr = [array]$input_arr

if ($PSCompletions.config.comp_config.$root.disable_hooks -eq 1) {
# 使用 hooks 覆盖默认的函数,实现在一些特殊的需求,比如一些补全的动态加载
if ($PSCompletions.config.comp_config.$root.disable_hooks -ne 1) {
. "$($PSCompletions.path.completions)/$root/hooks.ps1"
}
# 使用 hooks 覆盖默认的函数,实现在一些特殊的需求,比如一些补全的动态加载
if ($PSCompletions.config.comp_config.$root.disable_hooks -notin @($null, 1)) {
. "$($PSCompletions.path.completions)/$root/hooks.ps1"
}
if (!$PSCompletions.completions_data.$root) {
$common_options = @()
Expand Down Expand Up @@ -1064,6 +1062,15 @@ Add-Member -InputObject $PSCompletions -MemberType ScriptMethod init_data {
$language = if ($PSCompletions.language -eq 'zh-CN') { 'zh-CN' }else { 'en-US' }
$PSCompletions.info = $PSCompletions.ConvertFrom_JsonToHashtable($PSCompletions.get_raw_content("$($PSCompletions.path.completions)/psc/language/$language.json")).info
}
# XXX: 在 Windows PowerShell 5.x 中,边框使用以下符号以处理兼容性问题
if ($PSEdition -ne 'Core') {
$PSCompletions.config.horizontal = '-'
$PSCompletions.config.vertical = '|'
$PSCompletions.config.top_left = '+'
$PSCompletions.config.bottom_left = '+'
$PSCompletions.config.top_right = '+'
$PSCompletions.config.bottom_right = '+'
}
}
Add-Member -InputObject $PSCompletions.menu -MemberType ScriptMethod get_length {
param([string]$str)
Expand Down Expand Up @@ -1338,8 +1345,21 @@ if ($PSCompletions.config.enable_module_update -notin @(0, 1)) {
if ($PSCompletions.version_list[0] -ne $PSCompletions.version) {
$PSCompletions.wc.DownloadFile("$($PSCompletions.url)/module/CHANGELOG.json", (Join-Path $PSCompletions.path.temp 'CHANGELOG.json'))
$null = $PSCompletions.confirm_do($PSCompletions.info.module.update, {
$PSCompletions.write_with_color($PSCompletions.replace_content($PSCompletions.info.module.updating))
Update-Module PSCompletions -RequiredVersion $PSCompletions.version_list[0] -Force -ErrorAction Stop
$cmd_list = @(
"Update-Module PSCompletions -RequiredVersion $($PSCompletions.version_list[0]) -Force -ErrorAction Stop",
"Update-PSResource PSCompletions -Version $($PSCompletions.version_list[0]) -Force -ErrorAction Stop",
"Scoop update pscompletions"
)
foreach ($update_cmd in $cmd_list) {
try {
$PSCompletions.write_with_color($PSCompletions.replace_content($PSCompletions.info.module.updating))
Invoke-Expression $update_cmd
break
}
catch {
Write-Host $_ -ForegroundColor Red
}
}
})
}
else {
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.2
5.1.3

0 comments on commit 9f2b8b9

Please sign in to comment.