Skip to content

layout: Properly count characters when segmenting IFC text#42399

Merged
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:fix-character-counting
Feb 6, 2026
Merged

layout: Properly count characters when segmenting IFC text#42399
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:fix-character-counting

Conversation

@mrobinson
Copy link
Copy Markdown
Member

There was a bug where characters were not properly counted when
segmeting IFC text. Immediately incrementing the
current_character_index meant that the count was always one character
off. This character count is mainly used for drawing selections and
really matters when multiple text segments are in a single IFC. This
change fixes that by counting characters in the same way we were
counting byte indices for the text.

Testing: This change adds a Servo-specific WPT-style test. As it is quite
difficult to reproduce the correct display in a different way, a mismatch test
is used. Since this is mainly about appearance and is very specific to our
implementation the test is Servo-specific.
Fixes: #42354.

@mrobinson mrobinson requested a review from Loirooriol as a code owner February 6, 2026 10:48
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 6, 2026
There was a bug where characters were not properly counted when
segmeting IFC text. Immediately incrementing the
`current_character_index` meant that the count was always one character
off. This character count is mainly used for drawing selections and
really matters when multiple text segments are in a single IFC. This
change fixes that by counting characters in the same way we were
counting byte indices for the text.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson mrobinson force-pushed the fix-character-counting branch from c839ba5 to c11df50 Compare February 6, 2026 10:49
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Feb 6, 2026
@mrobinson mrobinson added this pull request to the merge queue Feb 6, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 6, 2026
Merged via the queue into servo:main with commit edbce7e Feb 6, 2026
29 checks passed
@mrobinson mrobinson deleted the fix-character-counting branch February 6, 2026 14:44
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 6, 2026
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.

Text caret is unable to select the last character in a certain case

3 participants