Skip to content

fix(language-service): use textEdit for version completion and fix empty range handling#135

Open
luo2430 wants to merge 1 commit into
npmx-dev:mainfrom
luo2430:main
Open

fix(language-service): use textEdit for version completion and fix empty range handling#135
luo2430 wants to merge 1 commit into
npmx-dev:mainfrom
luo2430:main

Conversation

@luo2430

@luo2430 luo2430 commented Jun 28, 2026

Copy link
Copy Markdown

解决以下问题

问题一(空字符串时代码提示全是*)

屏幕截图 2026-06-28 132424

问题二(vscode 默认的 word range 不包含 ^(非单词字符),导致 ^ 未被替换而是在前面又插入了一个 ^0.0.1)

屏幕截图 2026-06-28 134810 屏幕截图 2026-06-28 134819

…pty range handling

- Replace `insertText` with `textEdit` in version completion items to precisely replace the version range in the document.
- Fix `formatUpgradeVersion` to return the new version directly when the current range is empty (was incorrectly returning `*`).
- Update corresponding test case.
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7aee98a7-b459-4465-9e94-66a53dc6a0b7

📥 Commits

Reviewing files that changed from the base of the PR and between b14676c and b3ec29d.

📒 Files selected for processing (3)
  • packages/language-service/src/plugins/version-completion.ts
  • packages/language-service/src/utils/version.test.ts
  • packages/language-service/src/utils/version.ts

📝 Walkthrough

Walkthrough

getVersionRangePrefix is narrowed so that only the exact string '*' returns a wildcard prefix; empty strings no longer match. A corresponding test expectation for an empty rawSpec is updated from '*' to '2.0.0'. In the completion provider, each completion item is changed from using insertText to a textEdit that carries a range derived from dep.specRange and sets newText to the formatted version string.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the code changes, covering empty-spec completion and the caret range replacement fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@9romise 9romise left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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