Skip to content

Fix Word Duplication at Wrap Boundaries#122

Open
matiaskorhonen wants to merge 2 commits intoCodeEditApp:mainfrom
matiaskorhonen:fix/word-wrap-duplication
Open

Fix Word Duplication at Wrap Boundaries#122
matiaskorhonen wants to merge 2 commits intoCodeEditApp:mainfrom
matiaskorhonen:fix/word-wrap-duplication

Conversation

@matiaskorhonen
Copy link

Description

When a long line wraps, words at the wrap boundary get duplicated — appearing at the end of one visual line and again at the start of the next.

suggestLineBreak returns a position in the string, but it was passed directly as a length to NSRange. On the first fragment this works by coincidence (position equals length when starting at 0), but on subsequent fragments the length is too large by startOffset, causing each CTLine to include characters already rendered in the previous fragment.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Before After
before after

matiaskorhonen and others added 2 commits March 14, 2026 17:56
suggestLineBreak returns a position in the string, but it was passed
directly as a length to NSRange. On the first fragment this works by
coincidence (position equals length when starting at 0), but on
subsequent fragments the length is too large by startOffset, causing
each CTLine to include characters already rendered in the previous
fragment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant