Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/highlighters/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ This highlighter defines the following styles:
* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`)
* `back-double-quoted-argument` - backslash escape sequences inside double-quoted arguments (`\"` in `"foo\"bar"`)
* `back-dollar-quoted-argument` - backslash escape sequences inside dollar-quoted arguments (`\x` in `$'\x48'`)
* `function-definition` - function name(s) when defining a function (`f` and `g` in `f g () { : }`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases (written before I read the diff):

function { pwd } — anonymous function

function pwd — defines a function named pwd, not runs that command

function >/dev/null { pwd } — anonymous function

function f >/dev/null { pwd } — named function with sticky redirection

function >/dev/null f { pwd } — syntax error (!)

The above also support an optional () after the function names and before the brace.

() {} — anonymous function

() pwd — anonymous function

() () () pwd — anonymous function for calling tor

The above also come in named variants.

function () () pwd — two anonymous functions

function f () () pwd — named function whose body is an anonymous function

function () f () pwd — anonymous function that defines a function named f

function () () f pwd — two anonymous functions, f is in command position (unknown-token)

Then there's the MULTI_FUNC_DEF variants of all these.

Then there's

unsetopt multifuncdef; function f g h { pwd } — creates a function named f. Probably a zsh bug, actually, but shouldn't we highlight g and h as errors nevertheless? (I saw the test for the non-function-syntax variant of this.)

Question: In () pwd, should the () be highlighted as a command position? What about function { pwd }?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another case (github didn't let me edit comment after I pressed the green button):

% function f
pwd
% f

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact: function >/dev/null f { pwd } is only a syntax error when right_brace_is_recognised_everywhere is true. The redirection makes it an anonymous function that executes f. The wonders of zsh's grammar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should the newline be highlighted as?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about highlighting it the same way as the newlines in

for 1 in foo bar baz
do
  echo $1
done

?

* `assign` - parameter assignments (`x=foo` and `x=( )`)
* `redirection` - redirection operators (`<`, `>`, etc)
* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
Expand Down
61 changes: 42 additions & 19 deletions highlighters/main/main-highlighter.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ _zsh_highlight_main_highlighter_highlight_list()
# - :regular: "Not a command word", and command delimiters are permitted.
# Mainly used to detect premature termination of commands.
# - :always: The word 'always' in the «{ foo } always { bar }» syntax.
# - :function: Function names after 'function' or before '()'
#
# When the kind of a word is not yet known, $this_word / $next_word may contain
# multiple states. For example, after "sudo -i", the next word may be either
Expand Down Expand Up @@ -651,8 +652,8 @@ _zsh_highlight_main_highlighter_highlight_list()

# The Great Fork: is this a command word? Is this a non-command word?
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
# Missing closing square bracket(s)
if (( in_redirection )) || _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
# Unfinished redirection or missing closing square bracket(s)
style=unknown-token
elif [[ $this_word == *':regular:'* ]]; then
# This highlights empty commands (semicolon follows nothing) as an error.
Expand All @@ -668,12 +669,39 @@ _zsh_highlight_main_highlighter_highlight_list()
next_word=':start:'
highlight_glob=true
fi
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
elif (( in_redirection )); then
if [[ $this_word == *:function:* ]]; then
this_word=':start:'
fi
if [[ $arg == ($'\x29'|'()') ]] || { [[ $arg == $'\x7d' ]] && $right_brace_is_recognised_everywhere }; then
style=unknown-token
else
_zsh_highlight_main_highlighter_highlight_argument 1 0
continue
fi
elif [[ $this_word == *':always:'* && $arg == 'always' ]]; then
# try-always construct
style=reserved-word # de facto a reserved word, although not de jure
next_word=':start:'
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
elif [[ $this_word == *:function:* ]]; then
if [[ $arg == '()' ]]; then
style=reserved-word
next_word=':start:'
elif [[ $arg == $'\x7b' ]]; then
style=reserved-word
next_word=':start:'
braces_stack='Y'"$braces_stack"
else
style=function-definition
next_word=':function:'
fi
elif [[ $this_word == *':start:'* ]]; then # $arg is the command word
if [[ $res != reserved && $arg != '()' && ( $args[1] == '()' ||
# TODO: Function names can be absurd; this handles the more common cases without invoking Cthulhu.
( $zsyh_user_options[multifuncdef] == on && $args[(r)*[^[:alnum:]_-]*] == '()' ) ) ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could do something along the line of "after function, everything that isn't a token (&&, >, etc) or the reserved words { or () is a function name? Haven't looked at Src/parse.c of this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function already has that in effect. This branch only effects words before ().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that's what I meant. "If one of the following words is (), and it's in the same simple command as the current word, then all intervening words [other than redirections] are function names" or something like this. Basically, we know that "everything from the start of the command to the () token is function names", with some exceptions (noglob, redirections, …), so I wonder if a blacklist might be better than a whitelist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be a better approach, but I'm not sure how to keep it fast or how to enumerate all of the invalid function names.

(Aside noglob () pwd is a valid function definition.)

style=function-definition
next_word=:function:
elif (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
style=precommand
flags_with_argument=${precommand_options[$arg]%:*}
flags_sans_argument=${precommand_options[$arg]#*:}
Expand Down Expand Up @@ -746,6 +774,10 @@ _zsh_highlight_main_highlighter_highlight_list()
#
# The repeat-count word will be handled like a redirection target.
this_word=':start::regular:'
;;
('function')
next_word=':function:'
;;
esac
;;
'suffix alias') style=suffix-alias;;
Expand Down Expand Up @@ -831,8 +863,6 @@ _zsh_highlight_main_highlighter_highlight_list()
style=assign
in_array_assignment=false
next_word+=':start:'
elif (( in_redirection )); then
style=unknown-token
else
if _zsh_highlight_main__stack_pop 'S'; then
REPLY=$start_pos
Expand All @@ -841,24 +871,17 @@ _zsh_highlight_main_highlighter_highlight_list()
fi
_zsh_highlight_main__stack_pop 'R' reserved-word
fi;;
$'\x28\x29') # possibly a function definition
if (( in_redirection )) || $in_array_assignment; then
style=unknown-token
else
if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
then
next_word+=':start:'
fi
style=reserved-word
fi
'()')
# Function definition was handled above
style=unknown-token
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When can this happen? f g () with nomultifuncdef, function "foo'bar" (), …?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or after a redirection or in an array assignment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about empty case patterns? case foo in (bar) ;; esaccase foo in () ;; esac

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it's highlighted as reserved-word which isn't correct either. We'll probably need another state to handle case correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this branch the () in case is highlighted as unknown-token — which is correct, since it's a syntax error. Let's discuss case on #406.

;;
*) if false; then
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
# Parsing rule: {
#
# Additionally, `tt(})' is recognized in any position if neither the
# tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.
if (( in_redirection )) || $in_array_assignment; then
if $in_array_assignment; then
style=unknown-token
else
_zsh_highlight_main__stack_pop 'Y' reserved-word
Expand All @@ -873,7 +896,7 @@ _zsh_highlight_main_highlighter_highlight_list()
elif [[ $arg == $'\x5d' ]] && _zsh_highlight_main__stack_pop 'Q' builtin; then
:
else
_zsh_highlight_main_highlighter_highlight_argument 1 $(( 1 != in_redirection ))
_zsh_highlight_main_highlighter_highlight_argument 1 1
continue
fi
;;
Expand Down
14 changes: 7 additions & 7 deletions highlighters/main/test-data/function-altsyntax.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ BUFFER=$'function f { pwd }; function { pwd }'

expected_region_highlight=(
'1 8 reserved-word' # function
'10 10 default' # f
'12 12 reserved-word "issue #237"' # {
'14 16 command "issue #237"' # pwd
'18 18 reserved-word "issue #237"' # }
'10 10 function-definition' # f
'12 12 reserved-word' # {
'14 16 builtin' # pwd
'18 18 reserved-word' # }
'19 19 commandseparator' # ;
'21 28 reserved-word' # function
'30 30 reserved-word "issue #237"' # {
'32 34 command "issue #237"' # pwd
'36 36 reserved-word "issue #237"' # }
'30 30 reserved-word' # {
'32 34 builtin' # pwd
'36 36 reserved-word' # }
)
40 changes: 40 additions & 0 deletions highlighters/main/test-data/function-both.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/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
# -------------------------------------------------------------------------------------------------

BUFFER='function foo () { : }'

expected_region_highlight=(
'1 8 reserved-word' # function
'10 12 function-definition' # foo
'14 15 reserved-word' # ()
'17 17 reserved-word' # {
'19 19 builtin' # :
'21 21 reserved-word' # }
)
42 changes: 42 additions & 0 deletions highlighters/main/test-data/function-multifuncdef-off.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/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
# -------------------------------------------------------------------------------------------------

setopt no_multifuncdef

BUFFER='foo bar () { : }'

expected_region_highlight=(
'1 3 unknown-token' # foo
'5 7 default' # bar
'9 10 unknown-token' # ()
'12 12 default' # {
'14 14 default' # :
'16 16 unknown-token' # }
)
40 changes: 40 additions & 0 deletions highlighters/main/test-data/function-multifuncdef-on.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/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
# -------------------------------------------------------------------------------------------------

BUFFER=$'foo bar () { : }'

expected_region_highlight=(
'1 3 function-definition' # foo
'5 7 function-definition' # bar
'9 10 reserved-word' # ()
'12 12 reserved-word' # {
'14 14 builtin' # :
'16 16 reserved-word' # }
)
4 changes: 2 additions & 2 deletions highlighters/main/test-data/function-named1.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
BUFFER='f() pwd; f() { balanced braces }'

expected_region_highlight=(
'1 1 TBD "issue #223"' # f
'1 1 function-definition' # f
'2 3 reserved-word' # ()
'5 7 builtin' # pwd
'8 8 commandseparator' # ;
'10 10 TBD "issue #223"' # f
'10 10 function-definition' # f
'11 12 reserved-word' # ()
'14 14 reserved-word' # {
'16 23 unknown-token' # balanced
Expand Down
6 changes: 3 additions & 3 deletions highlighters/main/test-data/function-named2.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
BUFFER='f g h () pwd'

expected_region_highlight=(
'1 1 TBD "issue #223"' # f
'3 3 TBD "issue #223"' # g
'5 5 TBD "issue #223"' # h
'1 1 function-definition' # f
'3 3 function-definition' # g
'5 5 function-definition' # h
'7 8 reserved-word' # ()
'10 12 builtin' # pwd
)
38 changes: 38 additions & 0 deletions highlighters/main/test-data/function10.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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
# -------------------------------------------------------------------------------------------------

BUFFER='function () () pwd'

expected_region_highlight=(
'1 8 reserved-word' # function
'10 11 reserved-word' # ()
'13 14 reserved-word' # ()
'16 18 builtin' # pwd
)
39 changes: 39 additions & 0 deletions highlighters/main/test-data/function11.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/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
# -------------------------------------------------------------------------------------------------

BUFFER='function f () () pwd'

expected_region_highlight=(
'1 8 reserved-word' # function
'10 10 function-definition' # f
'12 13 reserved-word' # ()
'15 16 reserved-word' # ()
'18 20 builtin' # pwd
)
Loading