From 0b3bb0e7c1a24ef04ad3be8c2abffa21d02ce584 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sun, 19 May 2019 10:03:56 +0200 Subject: [PATCH] Underline every valid entered path (#5872) * src/highlight: Underline every valid entered path * update CHANGELOG * fix highlight test --- CHANGELOG.md | 1 + src/fish_tests.cpp | 2 +- src/highlight.cpp | 7 ++----- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42295b9a4..4b1a2a33b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - $PATH is no longer reordered in child fishes (#5456). - `eval` is now implemented internally rather than being a function; as such, the evaluated code now shares the same argument scope as `eval` rather than being executed in a new scope (#4443). - An issue resulting in a certain class of parser errors not resulting in a non-zero `$status` has been corrected (3e055f). +- fish now underlines every valid entered path instead of just the last one. ### Syntax changes and new commands - None yet. diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 77c26b494..b993e2386 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -4418,7 +4418,7 @@ static void test_highlighting() { highlight_tests.push_back({ {L"cat", highlight_role_t::command}, - {L"/dev/null", highlight_role_t::param}, + {L"/dev/null", param_valid_path}, {L"|", highlight_role_t::statement_terminator}, // This is bogus, but we used to use "less" here and that doesn't have to be installed. {L"cat", highlight_role_t::command}, diff --git a/src/highlight.cpp b/src/highlight.cpp index f7075795a..0924407d4 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -1265,11 +1265,8 @@ const highlighter_t::color_array_t &highlighter_t::highlight() { // Must be an argument with source. if (node.type != symbol_argument || !node.has_source()) continue; - // See if this node contains the cursor. We check <= source_length so that, when backspacing - // (and the cursor is just beyond the last token), we may still underline it. - if (this->cursor_pos >= node.source_start && - this->cursor_pos - node.source_start <= node.source_length && - node_is_potential_path(buff, node, vars, working_directory)) { + // Underline every valid path. + if (node_is_potential_path(buff, node, vars, working_directory)) { // It is, underline it. for (size_t i = node.source_start; i < node.source_start + node.source_length; i++) { // Don't color highlight_role_t::error because it looks dorky. For example,