summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--graphics/src/text/editor.rs12
-rw-r--r--widget/src/text_editor.rs30
2 files changed, 25 insertions, 17 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs
index c488a51c..4b8f0f2a 100644
--- a/graphics/src/text/editor.rs
+++ b/graphics/src/text/editor.rs
@@ -456,10 +456,14 @@ impl editor::Editor for Editor {
}
}
Action::Scroll { lines } => {
- editor.action(
- font_system.raw(),
- cosmic_text::Action::Scroll { lines },
- );
+ let (_, height) = editor.buffer().size();
+
+ if height < i32::MAX as f32 {
+ editor.action(
+ font_system.raw(),
+ cosmic_text::Action::Scroll { lines },
+ );
+ }
}
}
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index 5b0b1b79..7c0b98ea 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -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()
},