only to the top and to the bottom in the canvas, cant jump around anymore

This commit is contained in:
filipriec
2025-04-06 23:16:15 +02:00
parent 5879b40e8c
commit 803c748738
4 changed files with 8 additions and 24 deletions

View File

@@ -33,11 +33,7 @@ pub async fn execute_action<S: CanvasState>(
return Ok("No fields to navigate.".to_string());
}
let current_field = state.current_field();
let new_field = if current_field == 0 {
num_fields - 1
} else {
current_field - 1
};
let new_field = current_field.saturating_sub(1);
state.set_current_field(new_field);
let current_input = state.get_current_input();
let max_cursor_pos = if current_input.is_empty() {
@@ -57,7 +53,7 @@ pub async fn execute_action<S: CanvasState>(
return Ok("No fields to navigate.".to_string());
}
let current_field = state.current_field();
let new_field = (current_field + 1) % num_fields;
let new_field = (state.current_field() + 1).min(num_fields - 1);
state.set_current_field(new_field);
let current_input = state.get_current_input();
let max_cursor_pos = if current_input.is_empty() {