diff --git a/app/src/terminal/model/grid/grid_handler.rs b/app/src/terminal/model/grid/grid_handler.rs index 9ccc1acc..5626f1ae 100644 --- a/app/src/terminal/model/grid/grid_handler.rs +++ b/app/src/terminal/model/grid/grid_handler.rs @@ -1119,8 +1119,8 @@ impl GridHandler { // Note that if any one of the two fragments has separator, we shouldn't // concatenate them. (Some(prev_line_fragment), Some(current_line_fragment)) - if prev_line_fragment.has_separator() - || current_line_fragment.has_separator() => + if !prev_line_fragment.has_separator() + && !current_line_fragment.has_separator() => { let mut fragment = prev_line_fragments.pop().expect("Fragment should exist"); @@ -1175,8 +1175,8 @@ impl GridHandler { match (current_line_fragments.last(), next_line_fragments.first()) { (Some(current_line_fragment), Some(next_line_fragment)) - if current_line_fragment.has_separator() - || next_line_fragment.has_separator() => + if !current_line_fragment.has_separator() + && !next_line_fragment.has_separator() => { let mut fragment = current_line_fragments.pop().expect("Fragment should exist"); diff --git a/app/src/terminal/model/grid/grid_handler_test.rs b/app/src/terminal/model/grid/grid_handler_test.rs index 9a24cd90..5f5ea2e2 100644 --- a/app/src/terminal/model/grid/grid_handler_test.rs +++ b/app/src/terminal/model/grid/grid_handler_test.rs @@ -1068,6 +1068,39 @@ fn test_possible_file_paths() { ); } +#[test] +fn test_possible_file_paths_across_wrapped_lines() { + let first_line = "src/modules/core/internal/utils/wrappers/adapters/"; + let second_line = "interfaces/implementations/factories/README.md"; + let full_path = format!("{first_line}{second_line}"); + let expected_range = Point { row: 0, col: 0 }..=Point { + row: 1, + col: second_line.len() - 1, + }; + let blockgrid = mock_blockgrid(&format!("{first_line}\n{second_line}")); + + for hover_point in [ + Point { + row: 0, + col: first_line.len() - 2, + }, + Point { row: 1, col: 5 }, + ] { + let possible_paths = blockgrid + .grid_handler + .possible_file_paths_at_point(hover_point); + + assert!( + possible_paths.iter().any(|possible_path| { + possible_path.path.path.as_str() == full_path.as_str() + && possible_path.path.line_and_column_num.is_none() + && possible_path.range == expected_range + }), + "expected wrapped file path candidate at {hover_point:?} in {possible_paths:?}" + ); + } +} + #[test] fn test_fragment_boundary_at_point() { let assert_fragment_boundary =