@@ -9,6 +9,7 @@ use ratatui::DefaultTerminal;
99use ratatui:: widgets:: ListState ;
1010use ui:: render_app;
1111use vortex:: error:: { VortexExpect , VortexResult } ;
12+ use vortex:: layout:: layouts:: flat:: FlatVTable ;
1213
1314mod app;
1415mod ui;
@@ -58,24 +59,48 @@ fn handle_normal_mode(app: &mut AppState, event: Event) -> HandleResult {
5859 // We send the key-up to the list state if we're looking at
5960 // the Layouts tab.
6061 match app. current_tab {
61- Tab :: Layout => app. layouts_list_state . select_previous ( ) ,
62+ Tab :: Layout => {
63+ if app. cursor . layout ( ) . is :: < FlatVTable > ( ) {
64+ app. tree_scroll_offset = app. tree_scroll_offset . saturating_sub ( 1 ) ;
65+ } else {
66+ app. layouts_list_state . select_previous ( ) ;
67+ }
68+ }
6269 Tab :: Segments => app. segment_grid_state . scroll_up ( 10 ) ,
6370 }
6471 }
6572 ( KeyCode :: Down | KeyCode :: Char ( 'j' ) , _)
6673 | ( KeyCode :: Char ( 'n' ) , KeyModifiers :: CONTROL ) => match app. current_tab {
67- Tab :: Layout => app. layouts_list_state . select_next ( ) ,
74+ Tab :: Layout => {
75+ if app. cursor . layout ( ) . is :: < FlatVTable > ( ) {
76+ app. tree_scroll_offset = app. tree_scroll_offset . saturating_add ( 1 ) ;
77+ } else {
78+ app. layouts_list_state . select_next ( ) ;
79+ }
80+ }
6881 Tab :: Segments => app. segment_grid_state . scroll_down ( 10 ) ,
6982 } ,
7083 ( KeyCode :: PageUp , _) | ( KeyCode :: Char ( 'v' ) , KeyModifiers :: ALT ) => {
7184 match app. current_tab {
72- Tab :: Layout => app. layouts_list_state . scroll_up_by ( 10 ) ,
85+ Tab :: Layout => {
86+ if app. cursor . layout ( ) . is :: < FlatVTable > ( ) {
87+ app. tree_scroll_offset = app. tree_scroll_offset . saturating_sub ( 10 ) ;
88+ } else {
89+ app. layouts_list_state . scroll_up_by ( 10 ) ;
90+ }
91+ }
7392 Tab :: Segments => app. segment_grid_state . scroll_up ( 100 ) ,
7493 }
7594 }
7695 ( KeyCode :: PageDown , _) | ( KeyCode :: Char ( 'v' ) , KeyModifiers :: CONTROL ) => {
7796 match app. current_tab {
78- Tab :: Layout => app. layouts_list_state . scroll_down_by ( 10 ) ,
97+ Tab :: Layout => {
98+ if app. cursor . layout ( ) . is :: < FlatVTable > ( ) {
99+ app. tree_scroll_offset = app. tree_scroll_offset . saturating_add ( 10 ) ;
100+ } else {
101+ app. layouts_list_state . scroll_down_by ( 10 ) ;
102+ }
103+ }
79104 Tab :: Segments => app. segment_grid_state . scroll_down ( 100 ) ,
80105 }
81106 }
@@ -93,8 +118,9 @@ fn handle_normal_mode(app: &mut AppState, event: Event) -> HandleResult {
93118 let selected = app. layouts_list_state . selected ( ) . unwrap_or_default ( ) ;
94119 app. cursor = app. cursor . child ( selected) ;
95120
96- // Reset the list scroll state.
121+ // Reset the list scroll state and tree scroll offset .
97122 app. layouts_list_state = ListState :: default ( ) . with_selected ( Some ( 0 ) ) ;
123+ app. tree_scroll_offset = 0 ;
98124 }
99125 }
100126 ( KeyCode :: Left | KeyCode :: Char ( 'h' ) , _)
@@ -103,8 +129,9 @@ fn handle_normal_mode(app: &mut AppState, event: Event) -> HandleResult {
103129 Tab :: Layout => {
104130 // Ascend back up to the Parent node
105131 app. cursor = app. cursor . parent ( ) ;
106- // Reset the list scroll state.
132+ // Reset the list scroll state and tree scroll offset .
107133 app. layouts_list_state = ListState :: default ( ) . with_selected ( Some ( 0 ) ) ;
134+ app. tree_scroll_offset = 0 ;
108135 }
109136 Tab :: Segments => app. segment_grid_state . scroll_left ( 20 ) ,
110137 }
@@ -192,8 +219,9 @@ fn handle_search_mode(app: &mut AppState, event: Event) -> HandleResult {
192219 }
193220 } ;
194221
195- // Reset the list scroll state.
222+ // Reset the list scroll state and tree scroll offset .
196223 app. layouts_list_state = ListState :: default ( ) . with_selected ( Some ( 0 ) ) ;
224+ app. tree_scroll_offset = 0 ;
197225
198226 app. clear_search ( ) ;
199227 // Return to normal mode.
0 commit comments