nushell/tests/repl
Wind 155934f783
make better messages for incomplete string (#12868)
# Description
Fixes: #12795

The issue is caused by an empty position of `ParseError::UnexpectedEof`.
So no detailed message is displayed.
To fix the issue, I adjust the start of span to `span.end - 1`. In this
way, we can make sure that it never points to an empty position.

After lexing item, I also reorder the unclosed character checking . Now
it will be checking unclosed opening delimiters first.

# User-Facing Changes
After this pr, it outputs detailed error message for incomplete string
when running scripts.

## Before
```
❯ nu -c "'ab"
Error: nu::parser::unexpected_eof

  × Unexpected end of code.
   ╭─[source:1:4]
 1 │ 'ab
   ╰────
> ./target/debug/nu -c "r#'ab"
Error: nu::parser::unexpected_eof

  × Unexpected end of code.
   ╭─[source:1:6]
 1 │ r#'ab
   ╰────
```
## After
```
> nu -c "'ab"
Error: nu::parser::unexpected_eof

  × Unexpected end of code.
   ╭─[source:1:3]
 1 │ 'ab
   ·   ┬
   ·   ╰── expected closing '
   ╰────
> ./target/debug/nu -c "r#'ab"
Error: nu::parser::unexpected_eof

  × Unexpected end of code.
   ╭─[source:1:5]
 1 │ r#'ab
   ·     ┬
   ·     ╰── expected closing '#
   ╰────
```


# Tests + Formatting
Added some tests for incomplete string.

---------

Co-authored-by: Ian Manske <ian.manske@pm.me>
2024-05-15 01:14:11 +00:00
..
mod.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_bits.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_cell_path.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_commandline.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_conditionals.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_config_path.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_config.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_converters.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_custom_commands.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_engine.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_env.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_help.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_hiding.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_ide.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_iteration.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_known_external.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_math.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_modules.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_parser.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_ranges.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_regex.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_signatures.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_spread.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_stdlib.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_strings.rs make better messages for incomplete string (#12868) 2024-05-15 01:14:11 +00:00
test_table_operations.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
test_type_check.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00
tests.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00