@@ -49,6 +49,7 @@ use crate::terminal::cli_agent_sessions::{
4949use crate :: terminal:: model:: ansi:: { self , InitShellValue } ;
5050use crate :: terminal:: model:: ansi:: { BootstrappedValue , PreexecValue } ;
5151use crate :: terminal:: model:: blocks:: { insert_block, TotalIndex } ;
52+ use crate :: terminal:: model:: grid:: grid_handler:: Link ;
5253use crate :: terminal:: model:: grid:: Dimensions as _;
5354use crate :: terminal:: model:: terminal_model:: WithinBlock ;
5455use crate :: terminal:: session_settings:: AgentToolbarChipSelection ;
@@ -3528,6 +3529,31 @@ fn test_link_at_range_trims_zero_width_spaces() {
35283529 } )
35293530}
35303531
3532+ #[ test]
3533+ fn test_try_link_at_range_returns_none_for_stale_block_link ( ) {
3534+ App :: test ( ( ) , |mut app| async move {
3535+ initialize_app_for_terminal_view ( & mut app) ;
3536+ let terminal = add_window_with_terminal ( & mut app, None ) ;
3537+
3538+ terminal. read ( & app, |view, _ctx| {
3539+ let model = view. model . lock ( ) ;
3540+ let stale_link = WithinModel :: BlockList ( WithinBlock :: new (
3541+ Link {
3542+ range : Point :: new ( 0 , 0 ) ..=Point :: new ( 0 , 10 ) ,
3543+ is_empty : false ,
3544+ } ,
3545+ BlockIndex ( model. block_list ( ) . blocks ( ) . len ( ) + 100 ) ,
3546+ crate :: terminal:: GridType :: Output ,
3547+ ) ) ;
3548+
3549+ assert_eq ! (
3550+ model. try_link_at_range( & stale_link, RespectObfuscatedSecrets :: No ) ,
3551+ None
3552+ ) ;
3553+ } ) ;
3554+ } )
3555+ }
3556+
35313557#[ test]
35323558fn test_scroll_position_doesnt_change_when_block_finished ( ) {
35333559 use futures_lite:: StreamExt ;
0 commit comments