Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Wrong offset with newlines #12

@hpique

Description

@hpique

The textView scrolls to the wrong offset when reaching the end of texts with newlines. The problem appears to be carectRectForPosition:, which reports the wrong rect for the end of document. See log and animated gif below.

Steps to reproduce:

  1. Use text: @"1\n2\n3\n4\n5\n6\n7\n8\n9\n10"
  2. Run example.
  3. Position cursor at the end. Type Intro. This will already cause a quick glitch.
  4. Move scroll up.
  5. Move scroll down. The offset will be wrong.

bug

Log:

textViewDidChangeSelection
scrollToVisibleCaretAnimated:1
position: <_UITextKitTextPosition: 0x8b7d760> (20F)
caretRect: {{25.920013, 44.860001}, {2, 25.359999}}
scrollToVisibleCaretAnimated:0
position: <_UITextKitTextPosition: 0x8b7d760> (20F)
caretRect: {{25.920013, 221.73999}, {2, 25.359999}}
shouldChangeTextInRange
ensureCaretIsVisibleWithReplacementText
scheduleScrollToVisibleCaretWithDelay
textViewDidChangeSelection
scrollToVisibleCaretAnimated:1
position: <_UITextKitTextPosition: 0x8d68c50> (21F)
caretRect: {{4, 245.59999}, {2, 25.359999}}
textViewDidChange
scrollToVisibleCaretAnimated:0
position: <_UITextKitTextPosition: 0x8d68c50> (21F)
caretRect: {{4, 245.59999}, {2, 25.359999}}
scrollToVisibleCaret
scrollToVisibleCaretAnimated:0
position: <_UITextKitTextPosition: 0x8d68c50> (21F)
caretRect: {{4, 245.59999}, {2, 25.359999}}
textViewDidChangeSelection
scrollToVisibleCaretAnimated:1
position: <_UITextKitTextPosition: 0x8c2d390> (18F)
caretRect: {{4, 221.73999}, {2, 25.359999}}
textViewDidChangeSelection
scrollToVisibleCaretAnimated:1
position: <_UITextKitTextPosition: 0x8d837d0> (21F)
caretRect: {{4, 54.719997}, {2, 25.359999}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions