File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2641,9 +2641,6 @@ impl Editor {
26412641 self . cy += 1 ;
26422642 self . cx = leading_spaces;
26432643 self . mode = Mode :: Insert ;
2644- if started_transaction {
2645- self . commit_transaction ( self . cursor_snapshot ( ) ) ;
2646- }
26472644
26482645 if self . cy >= self . vheight ( ) {
26492646 self . vtop += 1 ;
@@ -2676,9 +2673,6 @@ impl Editor {
26762673 self . notify_change ( runtime) . await ?;
26772674 self . cx = leading_spaces;
26782675 self . mode = Mode :: Insert ;
2679- if started_transaction {
2680- self . commit_transaction ( self . cursor_snapshot ( ) ) ;
2681- }
26822676 self . render ( buffer) ?;
26832677 }
26842678 Action :: MoveToTop => {
Original file line number Diff line number Diff line change @@ -93,6 +93,10 @@ impl PluginPanel {
9393 } else if self . selected >= self . rows . len ( ) {
9494 self . selected = self . rows . len ( ) - 1 ;
9595 }
96+
97+ if self . scroll > self . selected {
98+ self . scroll = self . selected ;
99+ }
96100 }
97101
98102 pub fn move_selection ( & mut self , delta : isize , height : usize ) {
@@ -324,4 +328,17 @@ mod tests {
324328 assert_eq ! ( event. selected_index, 1 ) ;
325329 assert_eq ! ( event. row. unwrap( ) . id, "b" ) ;
326330 }
331+
332+ #[ test]
333+ fn update_rows_clamps_scroll_to_remaining_rows ( ) {
334+ let mut panel = PluginPanel :: new ( "tree" . to_string ( ) , PanelConfig :: default ( ) ) ;
335+ panel. update_rows ( ( 0 ..10 ) . map ( |i| row ( & i. to_string ( ) ) ) . collect ( ) ) ;
336+ panel. selected = 8 ;
337+ panel. scroll = 6 ;
338+
339+ panel. update_rows ( vec ! [ row( "a" ) , row( "b" ) ] ) ;
340+
341+ assert_eq ! ( panel. selected, 1 ) ;
342+ assert_eq ! ( panel. scroll, 1 ) ;
343+ }
327344}
Original file line number Diff line number Diff line change @@ -855,6 +855,25 @@ async fn test_yank_and_paste() {
855855 // This depends on clipboard/register implementation
856856}
857857
858+ #[ tokio:: test]
859+ async fn test_direct_open_line_below_groups_insert_undo ( ) {
860+ let mut harness = EditorHarness :: with_content ( "Line 1\n Line 2" ) ;
861+
862+ harness
863+ . execute_action ( Action :: InsertLineBelowCursor )
864+ . await
865+ . unwrap ( ) ;
866+ harness. type_text ( "New line" ) . await . unwrap ( ) ;
867+ harness
868+ . execute_action ( Action :: EnterMode ( Mode :: Normal ) )
869+ . await
870+ . unwrap ( ) ;
871+
872+ harness. assert_buffer_contents ( "Line 1\n New line\n Line 2" ) ;
873+ harness. execute_action ( Action :: Undo ) . await . unwrap ( ) ;
874+ harness. assert_buffer_contents ( "Line 1\n Line 2" ) ;
875+ }
876+
858877#[ tokio:: test]
859878async fn test_editing_empty_buffer ( ) {
860879 let mut harness = EditorHarness :: new ( ) ;
You can’t perform that action at this time.
0 commit comments