Skip to content

0.94.x detect columns --combine-columns a..b range regression (off by 1) #13105

@Jiogo18

Description

@Jiogo18

Describe the bug

The range in detect columns --combine-columns a..b combines the columns of indices from a to b+1
but from a to b would make more sense.

I have a command to list installed packages with expac and format them in a table. I combine column0 and column1 (install date and time) with --combine-columns 0..1. With 0.94 this command now includes the third column too (name), so I had to change to 0..0 which doesn't make much sense.

How to reproduce

Case 1:

"a b c d\ne f g h\ni j k l" | detect columns --combine-columns 1..1 combines the columns b and c.

╭───┬───┬─────┬───╮
│ # │ a │  b  │ d │
├───┼───┼─────┼───┤
│ 0 │ e │ f g │ h │
│ 1 │ i │ j k │ l │
╰───┴───┴─────┴───╯

Case 2

"a b c d\ne f g h\ni j k l" | detect columns --combine-columns 1..2 combines the columns b, c and d.

╭───┬───┬───────╮
│ # │ a │   b   │
├───┼───┼───────┤
│ 0 │ e │ f g h │
│ 1 │ i │ j k l │
╰───┴───┴───────╯

Case 3

Or with the last example in help detect columns:
^ls -lh | detect columns --no-headers --skip 1 --combine-columns 5..7
The column5 is "day month time name" (respectively column5, column6, column7 and column8 combined), there is no column after this one.

Case 4

expac --timefmt="%Y-%m-%d %T" "%l\t%n %v %w" | detect columns --no-headers --combine-columns 0..1 | rename install_date name version reason | sort | last 100

╭───┬─────────────────────────────┬──────────┬──────────╮
│ # │        install_date         │   name   │ version  │
├───┼─────────────────────────────┼──────────┼──────────┤
│ 0 │ 2024-06-xx xx:xx:xx nushell │ 0.94.2-1 │ explicit │
╰───┴─────────────────────────────┴──────────┴──────────╯

Expected behavior

Case 1

Combining 1..1 is combining only b to itself, so no changes.

╭───┬───┬───┬───┬───╮
│ # │ a │ b │ c │ d │
├───┼───┼───┼───┼───┤
│ 0 │ e │ f │ g │ h │
│ 1 │ i │ j │ k │ l │
╰───┴───┴───┴───┴───╯

Case 2

Combining 1..2 is combining the columns at position 1 and 2.

╭───┬───┬─────┬───╮
│ # │ a │  b  │ d │
├───┼───┼─────┼───┤
│ 0 │ e │ f g │ h │
│ 1 │ i │ j k │ l │
╰───┴───┴─────┴───╯

Case 3

The column5 is "day month time" (respectively column5, column6 and column7 combined), column8 is "name"

Case 4

╭───┬─────────────────────┬─────────┬──────────┬──────────╮
│ # │    install_date     │  name   │ version  │  reason  │
├───┼─────────────────────┼─────────┼──────────┼──────────┤
│ 0 │ 2024-06-xx xx:xx:xx │ nushell │ 0.94.2-1 │ explicit │
╰───┴─────────────────────┴─────────┴──────────┴──────────╯

Screenshots

No response

Configuration

key value
version 0.94.2
major 0
minor 94
patch 2
branch makepkg
commit_hash be8c1dc
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.78.0 (9b00956e5 2024-04-29) (Arch Linux rust 1:1.78.0-1)
cargo_version cargo 1.78.0
build_time 2024-06-04 09:13:10 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, system-clipboard, trash, which
installed_plugins plot

Additional context

Same result when building with main.
This was not the case in previous versions (at least 0.91.0).

It seems that the test for the ^ls -lh case has been changed in #12894 but not the help menu:
https://github.com/nushell/nushell/pull/12894/files#diff-f69690f30d70f0849495a2d3b0fbf9638a83794eb0bbf0928561e9e0b774ee98R80

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions