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

@ -269,7 +269,7 @@ fn substring_errors_if_start_index_is_greater_than_end_index() {
cwd: dirs.test(), pipeline(
r#"
open sample.toml
| str substring 6..5 fortune.teller.phone
| str substring 6..4 fortune.teller.phone
"#
));
@ -342,7 +342,7 @@ fn substrings_the_input_and_treats_start_index_as_zero_if_blank_start_index_give
cwd: dirs.test(), pipeline(
r#"
open sample.toml
| str substring ..2 package.name
| str substring ..1 package.name
| get package.name
"#
));