Fix getOffsetForCaret to return correct value if contains widget span#98542
Fix getOffsetForCaret to return correct value if contains widget span#98542fluttergithubbot merged 2 commits intoflutter:masterfrom
Conversation
|
a friendly bump |
5d84323 to
8111db3
Compare
justinmc
left a comment
There was a problem hiding this comment.
LGTM 👍
Just a question below. Also CC @Renzo-Olivares just as a heads up, since this is somewhat related to rich text editing.
| int? codeUnitAtVisitor(int index, Accumulator offset) { | ||
| return null; | ||
| offset.increment(1); | ||
| return PlaceholderSpan.placeholderCodeUnit.codeUnitAt(0); |
There was a problem hiding this comment.
Are there any implications for doing this? Like I wonder, in the future if we support copying a WidgetSpan, will the plain text representation of the WidgetSpan be \uFFFC?
There was a problem hiding this comment.
This method is mainly used to calculate layout geometry. I would imagine the copying use the toPlainText instead, or something like toRichText. It has to return something when this method is called, returning null at index within a string seems counter-intuitive.
There was a problem hiding this comment.
Sounds good, it shouldn't matter at all for copying then. The \uFFFC character makes sense to me here, I think that's what I was using as a placeholder when messing around with rich text editing.
| }) : super(style: style); | ||
|
|
||
| /// The unicode character to represent a placeholder. | ||
| static const String placeholderCodeUnit = '\uFFFC'; |
There was a problem hiding this comment.
Is there a reason no to define this as an int code unit = 0xFFFC?
This way you could call buffer.writeCharCode() and avoid doing the slightly confusing placeholderCodeUnit.codeUnitAt(0) conversion in widget_span.dart
There was a problem hiding this comment.
Ok, I published #98971 as this PR has been merged already.
fixes #98458
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.