Fix out of bounds caret in TextEditor in some circumstances
This commit is contained in:
parent
3762c0590c
commit
73088a6fc1
1 changed files with 17 additions and 13 deletions
|
|
@ -569,23 +569,27 @@ where
|
|||
if state.is_focused {
|
||||
match internal.editor.cursor() {
|
||||
Cursor::Caret(position) => {
|
||||
let position = position + translation;
|
||||
let cursor =
|
||||
Rectangle::new(
|
||||
position + translation,
|
||||
Size::new(
|
||||
1.0,
|
||||
self.line_height
|
||||
.to_absolute(self.text_size.unwrap_or_else(
|
||||
|| renderer.default_size(),
|
||||
))
|
||||
.into(),
|
||||
),
|
||||
);
|
||||
|
||||
if bounds.contains(position) {
|
||||
if let Some(clipped_cursor) = bounds.intersection(&cursor) {
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds: Rectangle {
|
||||
x: position.x.floor(),
|
||||
y: position.y,
|
||||
width: 1.0,
|
||||
height: self
|
||||
.line_height
|
||||
.to_absolute(
|
||||
self.text_size.unwrap_or_else(
|
||||
|| renderer.default_size(),
|
||||
),
|
||||
)
|
||||
.into(),
|
||||
x: clipped_cursor.x.floor(),
|
||||
y: clipped_cursor.y,
|
||||
width: clipped_cursor.width,
|
||||
height: clipped_cursor.height,
|
||||
},
|
||||
..renderer::Quad::default()
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue