Highlight the = in variable assignments as an operator

This commit is contained in:
ridiculousfish 2020-08-10 16:41:56 -07:00
parent 7254dfecb2
commit 703e6f571e
2 changed files with 8 additions and 6 deletions

View file

@ -4933,7 +4933,9 @@ static void test_highlighting() {
});
highlight_tests.push_back({
{L"HOME=.", highlight_role_t::param},
{L"HOME", highlight_role_t::param},
{L"=", highlight_role_t::operat, ns},
{L".", highlight_role_t::param, ns},
{L"false", highlight_role_t::command},
{L"|&", highlight_role_t::error},
{L"true", highlight_role_t::command},
@ -4952,7 +4954,8 @@ static void test_highlighting() {
});
highlight_tests.push_back({
{L"a=", highlight_role_t::param},
{L"a", highlight_role_t::param},
{L"=", highlight_role_t::operat, ns},
});
auto &vars = parser_t::principal_parser().vars();

View file

@ -1034,10 +1034,9 @@ 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);
// TODO: Color the '=' in the variable assignment as an operator, for fun.
// if (auto where = variable_assignment_equals_pos(varas.source(this->buff))) {
// this->color_array.at(*where) = highlight_role_t::operat;
// }
if (auto where = variable_assignment_equals_pos(varas.source(this->buff))) {
this->color_array.at(*where) = highlight_role_t::operat;
}
}
void highlighter_t::visit(const ast::decorated_statement_t &stmt) {