Skip to content

Fill up rows as much as possible in LeftToRight direction #6

Closed
@tertsdiepraam

Description

@tertsdiepraam

Below is a test adapted from the test in ogham/rust-term-grid#15. It currently fails in this fork too.

#[test]
fn theoretical_is_effective_max_num_line() {
    let mut grid = Grid::new(GridOptions {
        filling: Filling::Text("||".into()),
        direction: Direction::LeftToRight,
    });

    for s in [
        "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10",
        "test11",
    ] {
        grid.add(Cell::from(s));
    }

    let bits =
        "test1 ||test2 ||test3||test4||test5||test6||test7||test8||test9\ntest10||test11||\n";

    let display = grid.fit_into_width(69).unwrap();
    assert_eq!(display.to_string(), bits);
    assert_eq!(display.row_count(), 2);
}

Expected behaviour:

test1 ||test2 ||test3||test4||test5||test6||test7||test8||test9
test10||test11||

Actual behaviour:

test1||test2||test3||test4 ||test5 ||test6
test7||test8||test9||test10||test11||

This expected behaviour matches the behaviour of GNU ls:

❯ ls --sort=version -x
test1   test2   test3  test4  test5  test6  test7  test8  test9
test10  test11

However, this behaviour changes in the column format:

❯ ls --sort=version
test1  test3  test5  test7  test9   test11
test2  test4  test6  test8  test10

Note how it's not:

test1  test3  test5  test6 test7  test8  test9  test10  test11
test2  test4

We have three options to proceed:

  • Settle on one behaviour and document the difference with GNU in uutils/coreutils.
  • Make this behaviour configurable regardless of direction.
  • Make Direction::LeftToRight fill up as much of the lines and make Direction::TopToBottom fill up columns.

I'd like to coordinate also with the exa folks to determine whether they want to use this fork too and what behaviour they want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions