main: Run the entirety of aliases through the state machine

Fixes #540 #544 #552 #554 #555
This commit is contained in:
Matthew Martin
2018-10-17 21:38:17 -05:00
parent 2d4fe988ba
commit cb8c736a56
15 changed files with 108 additions and 52 deletions

View File

@@ -33,5 +33,6 @@ alias x=$'# foo\npwd'
BUFFER='x'
expected_region_highlight=(
"1 1 alias 'interactivecomments applies to aliases'" # x becomes pwd
'1 1 alias' # x
'1 1 comment' # x (#)
)

View File

@@ -33,5 +33,6 @@ alias x=$'# foo\npwd'
BUFFER='x'
expected_region_highlight=(
"1 1 unknown-token" # x becomes #
'1 1 alias' # x
'1 1 unknown-token' # x (#)
)

View File

@@ -33,7 +33,8 @@ alias a=b b=c c=b
BUFFER='a foo; :'
expected_region_highlight=(
'1 1 unknown-token' # a
'1 1 alias' # a
'1 1 unknown-token' # a (invalid alias loop)
'3 5 default' # foo
'6 6 commandseparator' # ;
'8 8 builtin' # :

View File

@@ -35,6 +35,7 @@ BUFFER='a -u phy1729 echo; :'
expected_region_highlight=(
'1 1 alias' # a
'1 1 precommand' # a (sudo)
'3 4 single-hyphen-option' # -u
'6 12 default' # phy1729
'14 17 builtin' # echo

View File

@@ -34,6 +34,7 @@ BUFFER='a foo; :'
expected_region_highlight=(
'1 1 alias' # a
'1 1 builtin' # a (:)
'3 5 default' # foo
'6 6 commandseparator' # ;
'8 8 builtin' # :

View File

@@ -35,7 +35,8 @@ BUFFER='sdu phy1729 echo foo'
expected_region_highlight=(
'1 3 alias' # sdu
'5 11 default "issue #540"' # phy1729
'1 3 precommand' # sdu (sudo)
'5 11 default' # phy1729
'13 16 commmand "issue #540"' # echo (not builtin)
'18 20 default' # foo
)

View File

@@ -0,0 +1,43 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2018 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias sde='sudo -e'
alias seu='sde -u'
sudo(){}
BUFFER='seu phy1729 echo foo'
expected_region_highlight=(
'1 3 alias' # seu
'1 3 precommand' # seu (sudo)
'5 11 default' # phy1729
'13 16 commmand "issue #540"' # echo (not builtin)
'18 20 default' # foo
)

View File

@@ -35,5 +35,5 @@ expected_region_highlight=(
'1 3 unknown-token' # "a"
'5 7 default' # foo
'8 8 commandseparator' # ;
'10 12 command "issue #544' # \ls
'10 12 command' # \ls
)

View File

@@ -31,7 +31,8 @@ alias x=\>
BUFFER='x foo echo bar'
expected_region_highlight=(
'1 1 redirection' # x becomes >
'1 1 alias' # x
'1 1 redirection' # x (>)
'3 5 default' # foo
'7 10 builtin' # echo
'12 14 default' # bar

View File

@@ -34,5 +34,6 @@ BUFFER='echo bar'
expected_region_highlight=(
'1 4 alias' # echo
'1 4 builtin' # echo
'6 8 default' # bar
)

View File

@@ -32,5 +32,6 @@ alias x=/
BUFFER=$'x'
expected_region_highlight=(
'1 1 unknown-token' # x
'1 1 alias' # x
'1 1 unknown-token "issue #202"' # x (/)
)

View File

@@ -48,4 +48,5 @@ fi
expected_region_highlight+=(
"9 9 commandseparator" # ;
"11 16 alias" # alias1
"11 16 command" # alias1 (ls)
)

View File

@@ -32,5 +32,6 @@ BUFFER='x ls'
expected_region_highlight=(
"1 1 alias" # x
"1 1 precommand" # x (command)
"3 4 command" # ls
)

View File

@@ -33,8 +33,9 @@ f() {}
BUFFER='a;f;'
expected_region_highlight=(
"1 1 alias" # f
"1 1 alias" # a
"1 1 builtin" # a (:)
"2 2 commandseparator" # ;
"3 3 function" # g
"3 3 function" # f
"4 4 commandseparator" # ;
)