fix range semantic in detect_columns, str substring, str index-of (#12894)

# Description
Fixes: https://github.com/nushell/nushell/issues/7761

It's still unsure if we want to change the `range semantic` itself, but
it's good to keep range semantic consistent between nushell commands.

# User-Facing Changes
### Before
```nushell
❯ "abc" | str substring 1..=2
b
```
### After
```nushell
❯ "abc" | str substring 1..=2
bc
```

# Tests + Formatting
Adjust tests to fit new behavior
This commit is contained in:
Wind
2024-05-23 01:00:58 +08:00
committed by GitHub
parent 7ede90cba5
commit ac4125f8ed
6 changed files with 12 additions and 12 deletions

View File

@ -31,12 +31,12 @@ fn detect_columns_with_legacy_and_flag_c() {
(
"$\"c1 c2 c3 c4 c5(char nl)a b c d e\"",
"[[c1,c3,c4,c5]; ['a b',c,d,e]]",
"0..1",
"0..0",
),
(
"$\"c1 c2 c3 c4 c5(char nl)a b c d e\"",
"[[c1,c2,c3,c4]; [a,b,c,'d e']]",
"(-2)..(-1)",
"(-2)..(-2)",
),
(
"$\"c1 c2 c3 c4 c5(char nl)a b c d e\"",
@ -77,7 +77,7 @@ drwxr-xr-x 4 root root 4.0K Mar 20 08:18 ~(char nl)
['drwxr-xr-x', '4', 'root', 'root', '4.0K', 'Mar 20 08:18', '~'],
['-rw-r--r--', '1', 'root', 'root', '3.0K', 'Mar 20 07:23', '~asdf']
]";
let range = "5..7";
let range = "5..6";
let cmd = format!(
"({} | detect columns -c {} -s 1 --no-headers) == {}",
pipeline(body),