diff options
| author | akbash <akbash@herdr.dev> | 2026-09-15 17:20:51 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-15 16:20:51 +0200 |
| commit | 963f78f46c8f10d0bfc869f0ea13223892a1f0ef (patch) | |
| tree | e89921c57548bf715fa26eff114909e8670c2f84 /src/client/shell/tests/mouse_selection.rs | |
| parent | 7808478d3bc7004b05aa41665ca11efb208033bd (diff) | |
fix: preserve live selections during pane output (#4193)
refs #3841
Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src/client/shell/tests/mouse_selection.rs')
| -rw-r--r-- | src/client/shell/tests/mouse_selection.rs | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/client/shell/tests/mouse_selection.rs b/src/client/shell/tests/mouse_selection.rs index ccb9b86d..ae4168c2 100644 --- a/src/client/shell/tests/mouse_selection.rs +++ b/src/client/shell/tests/mouse_selection.rs @@ -692,7 +692,7 @@ fn double_click_drag_autoscroll_keeps_absolute_word_anchor() { } #[test] -fn pane_content_updates_preserve_active_selection_only_when_selected_cells_stay_stable() { +fn pane_content_updates_preserve_live_ranges_until_geometry_or_screen_changes() { let mut state = ClientShellState::new(ClientShellConfig::from_config(&Config::default())); state.set_snapshot(Box::new(snapshot())); let surface_at = |surface_revision, content_revision, alternate_screen_active| { @@ -740,17 +740,42 @@ fn pane_content_updates_preserve_active_selection_only_when_selected_cells_stay_ assert!(selection.is_visible()); assert_eq!(selection.ordered_cells(), ((12, 0), (12, 1))); - state.selection = Some(crate::selection::Selection::absolute_anchor( - "pane_1".to_owned(), - (12, 0), - )); let mut replaced_surface = surface_at(3, 4, true); replaced_surface.frame.cells[4].symbol = "X".into(); state.set_pane_surface(replaced_surface); - assert!(state.selection.is_none()); + assert_eq!( + state.selection.as_ref().unwrap().ordered_cells(), + ((12, 0), (12, 1)) + ); + + // The selected row can leave the viewport during a drag. A later patch, + // including an in-flight content revision, must keep that absolute range. + let mut scrolled = surface_at(4, 5, true); + scrolled.panes[0] + .scroll + .as_mut() + .unwrap() + .offset_from_bottom = 2; + assert!(matches!( + state.apply_pane_surface_patch(crate::protocol::PaneSurfacePatch { + boot_id: scrolled.boot_id, + projection_revision: scrolled.projection_revision, + base_surface_revision: 3, + surface_revision: 4, + panes: scrolled.panes, + rows: vec![], + cursor: scrolled.frame.cursor, + }), + super::super::surface_patch::ClientPaneSurfacePatchOutcome::Applied(_) + )); + assert!(state.selection.as_ref().unwrap().is_in_progress()); + assert_eq!( + state.selection.as_ref().unwrap().ordered_cells(), + ((12, 0), (12, 1)) + ); for (surface_revision, content_revision, width, alternate_screen_active) in - [(4, 6, 4, false), (5, 8, 3, false), (6, 9, 3, false)] + [(5, 6, 4, false), (6, 8, 3, false)] { state.selection = Some(crate::selection::Selection::absolute_anchor( "pane_1".to_owned(), |
