-
Notifications
You must be signed in to change notification settings - Fork 1.3k
parameters-multi-word-machinery-v2 #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parameters-multi-word-machinery-v2 #684
Conversation
Works for me. Feel free to close #682. |
Not sure the commit from yesterday is quite right: would changing the condition have fixed the issue had the Blacklisting Also, review other |
Making that change on master fails tests, but passes them if
That bug can be seen by changing the diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh
index ea10268..44713a8 100644
--- a/highlighters/main/main-highlighter.zsh
+++ b/highlighters/main/main-highlighter.zsh
@@ -894,7 +894,7 @@ _zsh_highlight_main_highlighter_highlight_list()
_zsh_highlight_main__stack_pop 'R' reserved-word
else
if _zsh_highlight_main_highlighter_check_path $arg; then
- style=$REPLY
+ _zsh_highlight_main_add_region_highlight $start_pos $end_pos $REPLY
else
style=unknown-token
fi Then, trigger it: % tests/generate.zsh '$x foo' main x 'local x=/etc/passwd'
Set copyright year to 2020? y
local x=/etc/passwd
BUFFER=$'$x foo'
expected_region_highlight=(
'1 2 path' # $x
'1 2 unknown-token' # $x
'4 6 default' # foo
) The fact that the first addition's style is |
This happens because Presumably, the condition for that after-the-loop call should be changed. Perhaps something like If anyone sees a flaw in this plan, please speak up. |
Try adding |
With the diff in #684 (comment):
With that diff and the
(Note: That's just the differences between the two test runs. In both test runs, The first output shows the double entries; the second one does not. The second one also has |
…dy do for aliases. Fixes zsh-users#674.
They fail as follows: ZSH_PATCHLEVEL=debian/5.7.1-1 Running test brackets Running test main # parameter-value-contains-command-position1 1..2 not ok 1 - [1,7] «$foobar» - expected (1 7 "assign"), observed (1 7 "unknown-token"). ok 2 - cardinality check # parameter-value-contains-command-position2 1..2 not ok 1 - [1,2] «$y» - expected (1 2 "assign"), observed (1 2 "unknown-token"). ok 2 - cardinality check (The "unknown-token" was printed by the `_zsh_highlight_main_add_region_highlight` call on line 967, after the loop.) Before the parent commit, they behaved as follows (note the "BUG:" and "Bail out!" on the first one — that's issue zsh-users#670.2): ZSH_PATCHLEVEL=debian/5.7.1-1 # parameter-value-contains-command-position1 1..2 ok 1 - [1,7] «$foobar» - # TODO "issue zsh-users#670" not ok 2 - have 1 expectations and 6 region_highlight entries: «expected_region_highlight=( '1 7 assign "issue ♯670"' )» «region_highlight=( '0 7 assign' '2 7 default' '2 7 command-substitution-unquoted' zsh-syntax-highlighting: BUG: _zsh_highlight_highlighter_main_paint: start(2) >= end(2) Bail out! On './highlighters/main/test-data/parameter-value-contains-command-position2.zsh': output on stderr # parameter-value-contains-command-position2 1..2 ok 1 - [1,2] «$y» - # TODO "issue zsh-users#670" ok 2 - cardinality check
Current test failures: Running test main # parameter-value-contains-command-position1 1..2 ok 1 - [1,7] «$foobar» not ok 2 - have 1 expectations and 2 region_highlight entries: «expected_region_highlight=( '1 7 assign' )» «region_highlight=( '0 7 assign' '0 7 assign' )» # parameter-value-contains-command-position2 1..2 ok 1 - [1,2] «$y» not ok 2 - have 1 expectations and 2 region_highlight entries: «expected_region_highlight=( '1 2 assign' )» «region_highlight=( '0 2 assign' '0 2 assign' )»
In «a="b=c"; $a», the '=' sign in the expansion of $a is not active. Therefore, prevent the expansion of $a from being considered an assignment. Update test expectations accordingly. As a side effect, this prevents line 836 from firing for the cases in these two tests, thereby fixing the double $region_highlight addition (see log message of the previous commit). That leaves the line 966 addition. However, the double addition remains a latent bug (see discussion in PR zsh-users#684).
Fixes the bug the previous commit added a test for.
./.editorconfig is already set correctly.
For human readers' benefit.
- Print the test name and data after the plan line - Split on the plan line rather than on comments + That makes tap-filter more suitable to filter TAP output generated by other TAP producers. + However, the filtered output deletes the plan line and adds a blank line in its stead. This suits our use-case of interactive test runs.
a457529
to
fd95523
Compare
Rebased to master. Still have to handle the two WIP commits that tests fail on — can't merge that as-is, for future bisectors' benefit. |
I've edited the history to remove the fallback assignments to $param_style (since tests passed without them) and to make tests pass on every commit in the history (for future bisects). I pushed that edit as a new branch, https://github.com/zsh-users/zsh-syntax-highlighting/compare/master...danielshahaf:parameters-multi-word-machinery-v3?expand=1, since I didn't want to lose the pre-rebase version of the history. |
Merged in 2b3638a. |
Fix #670.
This is a revision of #675, an extension of the branch linked from #670 (comment), and obsoletes the patch posted in that comment. Relation to #682 TBD.
Reviews, please? If no issues are found, I'd like to merge this, wait for regression reports from users of master, and if none are received, release 0.7.0.