• auto-submit[bot]'s avatar
    Reverts "Changing `TextPainter.getOffsetForCaret` implementation to remove the... · f9b3b84d
    auto-submit[bot] authored
    Reverts "Changing `TextPainter.getOffsetForCaret` implementation to remove the logarithmic search (#143281)" (#143801)
    
    Reverts flutter/flutter#143281
    
    Initiated by: LongCatIsLooong
    
    Reason for reverting: https://github.com/flutter/flutter/issues/143797
    
    Original PR Author: LongCatIsLooong
    
    Reviewed By: {justinmc, jason-simmons}
    
    This change reverts the following previous change:
    Original Description:
    The behavior largely remains the same, except:
    
    1. The EOT cursor `(textLength, downstream)` for text ending in the opposite writing direction as the paragraph is now placed at the visual end of the last line. 
      For example, in a LTR paragraph, the EOT cursor for `aA` (lowercase for LTR and uppercase for RTL) is placed to the right of the line: `aA|` (it was `a|A` before). 
      This matches the behavior of most applications that do logical order arrow key navigation instead of visual order navigation. 
      And it makes the navigation order consistent for `aA\naA`:
    ```
      |aA    =>  aA|  => aA|  => aA  => aA   => aA 
       aA        aA      aA     |aA     aA|     aA|     
       (1)       (2)     (3)    (4)    (5)      (6)
    ```
    This is indeed still pretty confusing as (2) and (3), as well as (5) and (6) are hard to distinguish (when the I beam has a large width they are actually visually distinguishable -- they use the same anchor but one gets painted to the left and the other to the right. I noticed that emacs does the same). 
    But logical order navigation will always be confusing in bidi text, in one way or another.
    
    Interestingly there are 3 different behaviors I've observed in chrome:
    - the chrome download dialog (which I think uses GTK text widgets but not sure which version) gives me 2 cursors when navigating bidi text, and 
    - its HTML fields only show one, and presumably they place the I beam at the **trailing edge** of the character (which makes more sense for backspacing I guess). 
    - On the other hand, its (new) omnibar seems to use visual order arrow navigation
    
    Side note: we may need to update the "tap to place the caret here" logic to handle the case where the tap lands outside of the text and the text ends in the opposite writing direction. 
    
    2. Removed the logarithmic search. The same could be done using the characters package but when glyphInfo tells you about the baseline location in the future we probably don't need the `getBoxesForRange` call. This should fix https://github.com/flutter/flutter/issues/123424.
    
    ## Internal Tests
    
    This is going to change the image output of some internal golden tests. I'm planning to merge https://github.com/flutter/flutter/pull/143281 before this to avoid updating the same golden files twice for invalid selections.
    f9b3b84d
Name
Last commit
Last update
..
actions Loading commit data...
animated_grid Loading commit data...
animated_list Loading commit data...
app Loading commit data...
app_lifecycle_listener Loading commit data...
basic Loading commit data...
binding Loading commit data...
draggable_scrollable_sheet Loading commit data...
editable_text Loading commit data...
form Loading commit data...
gesture_detector Loading commit data...
hardware_keyboard Loading commit data...
heroes Loading commit data...
implicit_animations Loading commit data...
inherited_model Loading commit data...
interactive_viewer Loading commit data...
layout_builder Loading commit data...
magnifier Loading commit data...
navigator_pop_handler Loading commit data...
overlay Loading commit data...
page_view Loading commit data...
pop_scope Loading commit data...
routes Loading commit data...
scroll_notification_observer Loading commit data...
scroll_position Loading commit data...
scroll_view Loading commit data...
scrollbar Loading commit data...
shortcuts Loading commit data...
sliver Loading commit data...
slotted_render_object_widget Loading commit data...
tap_region Loading commit data...
text Loading commit data...
text_magnifier Loading commit data...
transitions Loading commit data...
navigator_utils.dart Loading commit data...