Skip to content

Caret clips off right edge of TextEditor #545

@Bip901

Description

@Bip901

Typing or arrow-navigating to the end of a long overflowing line causes the caret to become invisible (clipped ~2-4px off the right viewport edge).

The BringCaretToView() call (which is also presumably triggered by typing/arrow keys) undershoots at the document end, requiring manually dragging the horizontal scrollbar with the mouse to reveal the caret. This seems like a slight miscalculation, e.g. not accounting for the caret width.

For comparison, the regular Avalonia TextBox never clips the caret - once the end of the line has been reached, the caret stays fixed at the right side of the screen, despite keeping to type.

Minimal reproduction example (try typing a long line in both textboxes to feel the difference):

<Window
    x:Class="MainWindow"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ae="using:AvaloniaEdit"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Title="Example"
    Width="400"
    MinWidth="360"
    Padding="8"
    SizeToContent="Height">
    <StackPanel Orientation="Vertical">
        <ae:TextEditor
            x:Name="AvaloniaEditTextBox"
            Margin="8"
            FontSize="24"/>
        <TextBox
            x:Name="RegularTextBox"
            Margin="8"
            FontSize="24" />
    </StackPanel>
</Window>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions