From 05729b27a06d50d4d3516c1b62a2c7450e4ac12a Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 8 Apr 2024 01:49:38 +0200 Subject: [PATCH] Set a list offset --- src/list/state.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/list/state.rs b/src/list/state.rs index 35a906a3..d2ade97e 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -77,12 +77,15 @@ impl<'a> UiState<'a> { .highlight_symbol("🦀") .block(Block::default().borders(Borders::BOTTOM)); - let selected = 0; + let selected = state_file.next_exercise_ind(); + let table_state = TableState::default() + .with_offset(selected.saturating_sub(3)) + .with_selected(Some(selected)); Self { table, selected, - table_state: TableState::default().with_selected(Some(selected)), + table_state, last_ind: exercises.len() - 1, message: String::with_capacity(128), }