Skip to content

Commit eb33e4f

Browse files
Fix Word Duplication at Wrap Boundaries
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>
1 parent d7ac3f1 commit eb33e4f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/CodeEditTextView/TextLine/Typesetter/Typesetter.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ final public class Typesetter {
181181
)
182182

183183
// Indicates the subrange on the range that the typesetter knows about. This may not be the entire line
184-
let typesetSubrange = NSRange(location: context.currentPosition - range.location, length: lineBreak)
184+
let startOffset = context.currentPosition - range.location
185+
let typesetSubrange = NSRange(location: startOffset, length: lineBreak - startOffset)
185186
let typesetData = typesetLine(typesetter: typesetter, range: typesetSubrange)
186187

187188
// The typesetter won't tell us if 0 characters can fit in the constrained space. This checks to

0 commit comments

Comments
 (0)