mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-17 02:41:15 -03:00
Correct the positioning of the error caret
When an error occurs midway through a token, like abc(def, make the caret point at the location of the error (i.e. the paren) instead of at the beginning of the token.
This commit is contained in:
@@ -472,6 +472,26 @@ static void test_tok()
|
||||
err(L"Too few tokens returned from tokenizer");
|
||||
}
|
||||
}
|
||||
|
||||
/* Test some errors */
|
||||
{
|
||||
tok_t token;
|
||||
tokenizer_t t(L"abc\\", 0);
|
||||
do_test(t.next(&token));
|
||||
do_test(token.type == TOK_ERROR);
|
||||
do_test(token.error == TOK_UNTERMINATED_ESCAPE);
|
||||
do_test(token.error_offset == 3);
|
||||
}
|
||||
|
||||
{
|
||||
tok_t token;
|
||||
tokenizer_t t(L"abc defg(hij (klm)", 0);
|
||||
do_test(t.next(&token));
|
||||
do_test(t.next(&token));
|
||||
do_test(token.type == TOK_ERROR);
|
||||
do_test(token.error == TOK_UNTERMINATED_SUBSHELL);
|
||||
do_test(token.error_offset == 4);
|
||||
}
|
||||
|
||||
/* Test redirection_type_for_string */
|
||||
if (redirection_type_for_string(L"<") != TOK_REDIRECT_IN) err(L"redirection_type_for_string failed on line %ld", (long)__LINE__);
|
||||
|
||||
Reference in New Issue
Block a user