mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
Correctly highlight =s in var assignments after the first
We were not correctly offsetting the = in the token, it was always from the start of the string.
This commit is contained in:
parent
703e6f571e
commit
65f7f90433
2 changed files with 8 additions and 1 deletions
|
@ -4936,6 +4936,11 @@ static void test_highlighting() {
|
|||
{L"HOME", highlight_role_t::param},
|
||||
{L"=", highlight_role_t::operat, ns},
|
||||
{L".", highlight_role_t::param, ns},
|
||||
{L"VAR1", highlight_role_t::param},
|
||||
{L"=", highlight_role_t::operat, ns},
|
||||
{L"VAL1", highlight_role_t::param, ns},
|
||||
{L"VAR", highlight_role_t::param},
|
||||
{L"=", highlight_role_t::operat, ns},
|
||||
{L"false", highlight_role_t::command},
|
||||
{L"|&", highlight_role_t::error},
|
||||
{L"true", highlight_role_t::command},
|
||||
|
|
|
@ -1034,8 +1034,10 @@ void highlighter_t::visit(const ast::argument_t &arg, bool cmd_is_cd) {
|
|||
|
||||
void highlighter_t::visit(const ast::variable_assignment_t &varas) {
|
||||
color_as_argument(varas);
|
||||
// Highlight the '=' in variable assignments as an operator.
|
||||
if (auto where = variable_assignment_equals_pos(varas.source(this->buff))) {
|
||||
this->color_array.at(*where) = highlight_role_t::operat;
|
||||
size_t equals_loc = varas.source_range().start + *where;
|
||||
this->color_array.at(equals_loc) = highlight_role_t::operat;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue