-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix getOffsetForCaret to return correct value if contains widget span #98542
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
Conversation
|
a friendly bump |
5d84323 to
8111db3
Compare
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.