Skip to content

Commit 0cc6b90

Browse files
authored
input: Handle moving above the first line (sentriz#525)
1 parent 482a31f commit 0cc6b90

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/ui/src/input/input.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,13 @@ impl TextInput {
326326

327327
new_sub_line += direction;
328328

329+
// Handle moving above the first line
330+
if direction == -1 && new_line_index == 0 && new_sub_line < 0 {
331+
// Move cursor to the beginning of the text
332+
self.move_to(0, cx);
333+
return;
334+
}
335+
329336
if new_sub_line < 0 {
330337
if new_line_index > 0 {
331338
new_line_index -= 1;
@@ -345,6 +352,7 @@ impl TextInput {
345352
}
346353
}
347354

355+
// If after adjustment, still at the same position, do not proceed
348356
if new_line_index == current_line_index && new_sub_line == current_sub_line as i32 {
349357
return;
350358
}

0 commit comments

Comments
 (0)