mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 18:21:16 -03:00
Fix a tnode-related crash in syntax highlighting
Adds a new test too.
This commit is contained in:
@@ -3808,10 +3808,17 @@ static void test_highlighting(void) {
|
|||||||
{L"[3]", highlight_spec_param}, // two dollar signs, so last one is not an expansion
|
{L"[3]", highlight_spec_param}, // two dollar signs, so last one is not an expansion
|
||||||
{NULL, -1}};
|
{NULL, -1}};
|
||||||
|
|
||||||
const highlight_component_t *tests[] = {components1, components2, components3, components4,
|
const highlight_component_t components14[] = {{L"cat", highlight_spec_command},
|
||||||
components5, components6, components7, components8,
|
{L"/dev/null", highlight_spec_param},
|
||||||
components9, components10, components11, components12,
|
{L"|", highlight_spec_statement_terminator},
|
||||||
components13};
|
{L"less", highlight_spec_command},
|
||||||
|
{L"2>", highlight_spec_redirection},
|
||||||
|
{NULL, -1}};
|
||||||
|
|
||||||
|
const highlight_component_t *tests[] = {components1, components2, components3, components4,
|
||||||
|
components5, components6, components7, components8,
|
||||||
|
components9, components10, components11, components12,
|
||||||
|
components13, components14};
|
||||||
for (size_t which = 0; which < sizeof tests / sizeof *tests; which++) {
|
for (size_t which = 0; which < sizeof tests / sizeof *tests; which++) {
|
||||||
const highlight_component_t *components = tests[which];
|
const highlight_component_t *components = tests[which];
|
||||||
// Count how many we have.
|
// Count how many we have.
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ enum token_type redirection_type(tnode_t<grammar::redirection> redirection, cons
|
|||||||
}
|
}
|
||||||
if (out_target != NULL) {
|
if (out_target != NULL) {
|
||||||
tnode_t<grammar::tok_string> target = redirection.child<1>(); // like &1 or file path
|
tnode_t<grammar::tok_string> target = redirection.child<1>(); // like &1 or file path
|
||||||
*out_target = target ? target.get_source(src) : wcstring();
|
*out_target = target.has_source() ? target.get_source(src) : wcstring();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user