nushell/tests
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
..
assets/nu_json Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
const_ add raw-string literal support (#9956) 2024-05-02 09:36:37 -04:00
eval Exit early when encountering parsing errors (#10213) 2023-09-05 14:36:37 +02:00
fixtures Msgpack commands (#12664) 2024-04-26 06:23:16 -05:00
hooks Fix hooks on 0.92.0 (#12383) 2024-04-04 09:25:54 +02:00
modules Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
overlays Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
parsing Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
path Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
plugin_persistence Add a bit more delay before ps calls in plugin persistence tests (#12673) 2024-04-26 06:24:57 -05:00
plugins Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
repl make better messages for incomplete string (#12868) 2024-05-15 01:14:11 +00:00
scope Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
shell Fix raw strings as external argument (#12817) 2024-05-10 07:50:31 +08:00
main.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00