Skip to content

text: Preserve logical selection across presentation changes - #3421

Merged
huacnlee merged 4 commits into
longbridge:mainfrom
TomiXRM:fix/kagi-compatible-selection
Oct 9, 2026
Merged

huacnlee merged 4 commits into
longbridge:mainfrom
TomiXRM:fix/kagi-compatible-selection

Conversation

@TomiXRM

@TomiXRM TomiXRM commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Completed partial selections in a managed TextViewState should survive presentation changes when the source is unchanged. This PR retains the logical selection range and Copy payload across style, syntax-highlighter, inherited-font, zoom, and width changes by default. It adds no configuration API.

Current styles and wrapping still apply. The retained range is not reconstructed by projecting an old pointer rectangle onto the new layout, and later outer-layout origin changes do not become new selection gestures. A new drag or explicit clear updates selection normally. Source replacement and Markdown parser-configuration replacement still invalidate selection.

The owning view must retain both the state and its painted selection participant. This behavior does not pin rows unmounted by an outer virtual list. Changes are confined to SDK selection policy; GPUI and platform input are not patched. The changes were developed with AI assistance.

Motivation: Kagi issue #1091. This PR addresses selection behavior and does not claim to complete the broader conversation-performance work.

Public API

No public APIs are added, removed, or changed relative to the base branch. The opt-in builder proposed in earlier revisions has been removed; presentation-only changes now preserve completed selections by default.

Validation

Validated locally after commit 48cc5389a:

  • 331 Base and 69 Component tests selected by text::: all 400 passed.
  • 7 Kit text-selection integration tests: all passed. Fixtures use gpui_kit::open_window through the shared test helper.
  • cargo fmt --all --check: passed.
  • Clippy for Base, Component, Kit, and the text-selection integration target with --deny warnings: passed.
  • git diff --check: passed.

Coverage includes completed partial selection and Copy across color, width-only, font, zoom, and origin changes; cross-block and cross-renderer reflow; new drags replacing retained ranges; explicit clear; source replacement; and parser-configuration replacement. Syntax-highlighter changes apply new presentation while preserving the selection. The existing Component regression now verifies default retention after same-size style changes.

The Base README and English/Chinese TextView documentation describe the default behavior and mounted-participant requirement. Native GUI/performance evaluation has not been performed for this update. Results from CI on earlier revisions do not validate the latest head.

@TomiXRM
TomiXRM marked this pull request as draft October 8, 2026 17:19
@TomiXRM

TomiXRM commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

追加の静的レビューで、幅のみの変更と、その後のスクロールにおける論理選択保持に2件のリスクが見つかりました。既存1969件の通過だけではこの境界を保証できないため draft に戻しました。再現ケースを追加し、通常の追加commitで修正・再検証します。現在のheadを完成済みとは扱いません。

@TomiXRM

TomiXRM commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

追加commit 6c783a2 で2件を修正しました。幅単独の実リフロー、およびfont+width更新後の外側origin移動を、実ドラッグ・論理source range・Copy dispatch・複数paint・新規dragの回帰で検証しています。gpui-base/component test-support全1970件、fmt、Clippy通過。追加commitの静的再レビューでも先の2件の解消を確認しました。既定falseとsource/parser無効化は維持します。これらは公開headの検証で、main統合後のbuild/testは上流CIの結果を別途確認します。

@TomiXRM
TomiXRM marked this pull request as ready for review October 8, 2026 17:40
@huacnlee huacnlee changed the title feat(text): スタイル変更時の論理選択保持をオプトインで追加 text: Preserve logical selection across presentation changes with an opt-in Oct 9, 2026
@huacnlee huacnlee changed the title text: Preserve logical selection across presentation changes with an opt-in text: Preserve logical selection across presentation changes Oct 9, 2026
@huacnlee
huacnlee enabled auto-merge (squash) October 9, 2026 13:41
@huacnlee
huacnlee merged commit 0bbd987 into longbridge:main Oct 9, 2026
16 checks passed
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