Skip to content

Fix some ps1 issues#8

Merged
lc2panda merged 1 commit into
lc2panda:mainfrom
quickquickcode:fix-ps1-956c291
May 17, 2026
Merged

Fix some ps1 issues#8
lc2panda merged 1 commit into
lc2panda:mainfrom
quickquickcode:fix-ps1-956c291

Conversation

@quickquickcode
Copy link
Copy Markdown
Contributor

Summary

This PR fixes a set of PowerShell string interpolation issues in wps-office-mcp/scripts/wps-com.ps1 that affect Excel range expressions involving row and column references.

The main change is replacing patterns like:

  • "$col:$col"
  • "$startRow:$endRow"

with explicit variable boundaries such as:

  • "${col}:${col}"
  • "${startRow}:${endRow}"

This avoids ambiguous parsing when a variable is immediately followed by : in a double-quoted string.

Why

In PowerShell, variable interpolation can become error-prone when variable names are directly adjacent to characters like :. Using ${...} makes the intended variable boundaries explicit and ensures the generated range string is correct.

This is especially important for COM calls like:

  • Range(...).ColumnWidth = ...
  • Range(...).AutoFit()
  • Range(...).Insert()
  • Range(...).Delete()
  • Range(...).Hidden = $true / $false
  • Range(...).Group()

Scope of changes

Updated Excel-related range construction in the following operations inside wps-com.ps1:

  • set column width
  • autofit column
  • insert rows
  • insert columns
  • delete rows
  • delete columns
  • hide rows
  • hide columns
  • show rows
  • show columns
  • group columns

Impact

This change should improve reliability for Excel row/column range operations in the WPS COM bridge and prevent malformed range strings caused by ambiguous interpolation.

Notes

  • The change is limited to string construction for range references.
  • No intended behavior change beyond producing the correct COM range address.
  • This PR is based on commit: 956c29106abbe3503f57e8a311ee23566488059f

@lc2panda lc2panda merged commit ba437eb into lc2panda:main May 17, 2026
lc2panda added a commit that referenced this pull request May 17, 2026
PR #8 (quickquickcode) 合并修复 PowerShell 字符串插值致命bug时
意外引入 UTF-8 BOM (ef bb bf) 到 wps-com.ps1 首行。

BOM 在部分 powershell -File 解释器/CI 环境会破坏脚本运行,
按香草上校审查团队风险评估清单跟进清理。

验证:
- npm run build ✅
- npm test ✅ 101/101 全通过
- diff: 仅首行 -# → +# (1 byte 变化)
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.

2 participants