text input: EditableText::value() -> Cow<str> - #25532
Open
Cyannide wants to merge 1 commit into
Open
Conversation
Previously value() returned a parley SplitString, which required every consumer to reassemble the segments by hand for just about any use case. With Cow<str> (usually borrowed) most existing code continues working unchanged using deref, IME being an owned exception because of the preedit split during composition. FeathersNumberInput and the multiline/multiple-input examples converted to the new API with manual reassembly now one liners.
Cyannide
force-pushed
the
editable_text_value_cow
branch
from
August 24, 2026 03:04
d95bb48 to
4b2fa71
Compare
Cyannide
added a commit
to Cyannide/bevy
that referenced
this pull request
Aug 24, 2026
Rebased onto the value() -> Cow split (bevyengine#25532) The display buffer holds mask glyphs while the entered text lives in EditableText::shadow_value, and value() reads through the shadow into the entered text so the mask only affects the display. Paste routes through masked_insert so the clipboard string never exists in the visible buffer. Migration guide now in the Cow return PR.
Cyannide
added a commit
to Cyannide/bevy
that referenced
this pull request
Aug 24, 2026
Rebased onto the value() -> Cow split (bevyengine#25532) The display buffer holds mask glyphs while the entered text lives in EditableText::shadow_value, and value() reads through the shadow into the entered text so the mask only affects the display. Paste routes through masked_insert so the clipboard string never exists in the visible buffer. value() migration guide now part of the Cow return PR, the apply_pending_edits() guide still here.
Zeophlite
reviewed
Aug 24, 2026
| pub fn value(&self) -> SplitString<'_> { | ||
| self.editor.text() | ||
| /// Borrowed as default, owned copy returned when there is a split | ||
| /// (e.g. IME preedit). |
Contributor
There was a problem hiding this comment.
Could you explain the logic here, why is there first and second?
Contributor
Author
There was a problem hiding this comment.
Normally second is empty, but when an IME preedit is active, parley returns two segments, the part before and the part after the preedit. So the owned version combines the two.
Zeophlite
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Split out of #25117 as a standalone PR by reviewer suggestion to benefit other parley edit consumers.
Previously
EditableText::value()returned a parleySplitString, which required every consumer to reassemble the segments by hand for just about any use case.Solution
By returning a
Cow<str>(usually borrowed) most existing code continues working unchanged using deref, IME being an owned exception because of the preedit split during composition.Testing
FeathersNumberInput and the multiline/multiple-input examples converted to the new API (manual reassembly now one liners) run and exercised. Also tested with several call sites in a 0.19 backport for a production WASM and desktop app exercised by 1-8 grade students on their login screen every morning.
Migration
Guide included, existing call sites adopted in the PR.