Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support VSCode API: inputBox.valueSelection #4145

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

bk1012
Copy link
Member

@bk1012 bk1012 commented Nov 4, 2024

Types

  • 🎉 New Features

Background or solution

support VSCode API: inputBox.valueSelection

Changelog

Summary by CodeRabbit

  • 新功能

    • 在输入框中添加了 valueSelection 属性,允许用户选择输入值的范围。
    • 更新了输入框的显示逻辑,以更好地管理输入值的选择范围。
  • bug 修复

    • 简化了 QuickOpenWidgetvalueSelection 的访问方式,提升了性能。
  • 文档

    • 更新了 InputBox 接口的文档,说明了新属性的使用和行为。

Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

此拉取请求对 ExtHostQuickOpenExtQuickInput 类进行了多项修改,主要在 ext.host.quickopen.ts 文件中添加了一个新的私有属性 _valueSelection,用于跟踪输入值的选择范围。同时,更新了 showInputBox 方法以利用该属性,增强输入框的用户交互。quick-open.widget.tsx 文件中的 QuickOpenWidget 类也进行了相应修改,移除了 valueSelection 的计算装饰器。最后,在 vscode.quickpick.d.ts 文件中为 InputBox 接口添加了 valueSelection 属性,以增强用户输入能力。

Changes

文件路径 修改摘要
packages/extension/src/hosted/api/vscode/ext.host.quickopen.ts 添加私有属性 _valueSelection,以及其 getter 和 setter 方法;更新 showInputBoxgetOptions 方法以使用新属性。
packages/quick-open/src/browser/quick-open.widget.tsx 移除 valueSelection 的计算装饰器,简化对 _valueSelection 的访问。
packages/types/vscode/typings/vscode.quickpick.d.ts InputBox 接口中添加只读属性 valueSelection,表示输入值的选择范围。

Possibly related PRs

Suggested labels

🎨 feature

Suggested reviewers

  • Ricbet

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
packages/extension/src/hosted/api/vscode/ext.host.quickopen.ts (1)

Line range hint 673-691: 建议在 getOptions 中添加 valueSelection

当前 getOptions 方法没有包含 valueSelection 属性。为了确保选择范围能够正确同步到 UI,建议将其添加到返回的选项中。

建议按如下方式修改:

 getOptions(): QuickInputOptions {
   return {
     value: this.value,
+    valueSelection: this.valueSelection,
     prompt: this.prompt,
     placeHolder: this.placeholder,
     password: this.password,
     ignoreFocusOut: this.ignoreFocusOut,
     title: this._title,
     totalSteps: this.totalSteps,
     step: this.step,
     validationMessage:
       typeof this.validationMessage === 'string' ? this.validationMessage : this.validationMessage?.message,
     buttons: this.buttons as unknown as QuickTitleButton[],
     busy: this.busy,
     enabled: this.enabled,
     hideOnDidAccept: this.hideOnDidAccept,
   };
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 967717c and 9fa6ac7.

📒 Files selected for processing (3)
  • packages/extension/src/hosted/api/vscode/ext.host.quickopen.ts (2 hunks)
  • packages/quick-open/src/browser/quick-open.widget.tsx (0 hunks)
  • packages/types/vscode/typings/vscode.quickpick.d.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/quick-open/src/browser/quick-open.widget.tsx
🔇 Additional comments (3)
packages/types/vscode/typings/vscode.quickpick.d.ts (1)

380-389: 代码变更符合预期!

新增的 valueSelection 属性定义完整且清晰:

  • 类型定义为只读元组,确保了类型安全
  • 详细的文档说明了属性的用途和行为
  • InputBoxOptions 接口中的同名属性保持一致
  • 补充了重要的使用说明,特别是关于该属性不会随用户输入自动更新的提醒
packages/extension/src/hosted/api/vscode/ext.host.quickopen.ts (2)

449-449: 属性定义正确!

_valueSelection 属性的类型定义合理,使用 tuple 类型 [number, number] 来存储选择范围的起始和结束位置,并通过 | undefined 支持无选择状态。


569-576: 访问器实现完善!

getter 和 setter 的实现遵循了类中其他属性的模式:

  • getter 直接返回私有属性
  • setter 更新私有属性并通过 update 方法触发界面更新

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 54.22%. Comparing base (6b4c57e) to head (9fa6ac7).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...ension/src/hosted/api/vscode/ext.host.quickopen.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4145      +/-   ##
==========================================
- Coverage   54.23%   54.22%   -0.02%     
==========================================
  Files        1598     1598              
  Lines       97627    97657      +30     
  Branches    19968    19976       +8     
==========================================
+ Hits        52949    52952       +3     
- Misses      37110    37131      +21     
- Partials     7568     7574       +6     
Flag Coverage Δ
jsdom 49.78% <0.00%> (-0.02%) ⬇️
node 15.60% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erha19 erha19 merged commit 926108b into main Nov 7, 2024
13 checks passed
@erha19 erha19 deleted the feat/support-InputBox.valueSelection branch November 7, 2024 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎨 feature feature required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants