parent
ff61a496b5
commit
bdbe214453
@ -36,8 +36,11 @@ This highlighter defines the following styles:
|
|||||||
* `double-hyphen-option` - double hyphen options (`--option`)
|
* `double-hyphen-option` - double hyphen options (`--option`)
|
||||||
* `back-quoted-argument` - backquoted expressions (`` `foo` ``)
|
* `back-quoted-argument` - backquoted expressions (`` `foo` ``)
|
||||||
* `single-quoted-argument` - single quoted arguments (`` 'foo' ``)
|
* `single-quoted-argument` - single quoted arguments (`` 'foo' ``)
|
||||||
|
* `single-quoted-argument-unclosed` - unclosed single quoted arguments (`` 'foo ``)
|
||||||
* `double-quoted-argument` - double quoted arguments (`` "foo" ``)
|
* `double-quoted-argument` - double quoted arguments (`` "foo" ``)
|
||||||
|
* `double-quoted-argument-unclosed` - unclosed double quoted arguments (`` "foo ``)
|
||||||
* `dollar-quoted-argument` - dollar quoted arguments (`` $'foo' ``)
|
* `dollar-quoted-argument` - dollar quoted arguments (`` $'foo' ``)
|
||||||
|
* `dollar-quoted-argument-unclosed` - unclosed dollar quoted arguments (`` $'foo ``)
|
||||||
* `rc-quote` - two single quotes inside single quotes when the `RC_QUOTES` option is set (`` 'foo''bar' ``)
|
* `rc-quote` - two single quotes inside single quotes when the `RC_QUOTES` option is set (`` 'foo''bar' ``)
|
||||||
* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`)
|
* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`)
|
||||||
* `back-double-quoted-argument` - back double quoted arguments (`\x` inside `""`)
|
* `back-double-quoted-argument` - back double quoted arguments (`\x` inside `""`)
|
||||||
|
@ -85,6 +85,10 @@ _zsh_highlight_main_add_region_highlight() {
|
|||||||
# in _zsh_highlight_main_highlighter_highlight_path_separators().
|
# in _zsh_highlight_main_highlighter_highlight_path_separators().
|
||||||
path_pathseparator path
|
path_pathseparator path
|
||||||
path_prefix_pathseparator path_prefix
|
path_prefix_pathseparator path_prefix
|
||||||
|
|
||||||
|
single-quoted-argument{-unclosed,}
|
||||||
|
double-quoted-argument{-unclosed,}
|
||||||
|
dollar-single-quoted-argument{-unclosed,}
|
||||||
)
|
)
|
||||||
local needle=$1 value
|
local needle=$1 value
|
||||||
while [[ -n ${value::=$fallback_of[$needle]} ]]; do
|
while [[ -n ${value::=$fallback_of[$needle]} ]]; do
|
||||||
@ -840,7 +844,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
# Highlight single-quoted strings
|
# Highlight single-quoted strings
|
||||||
_zsh_highlight_main_highlighter_highlight_single_quote()
|
_zsh_highlight_main_highlighter_highlight_single_quote()
|
||||||
{
|
{
|
||||||
local arg1=$1 i q=\'
|
local arg1=$1 i q=\' style
|
||||||
local -a highlights
|
local -a highlights
|
||||||
i=$arg[(ib:arg1+1:)$q]
|
i=$arg[(ib:arg1+1:)$q]
|
||||||
|
|
||||||
@ -852,7 +856,12 @@ _zsh_highlight_main_highlighter_highlight_single_quote()
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
highlights=($(( start_pos + $1 - 1 )) $(( start_pos + i )) single-quoted-argument $highlights)
|
if [[ $arg[i] == "'" ]]; then
|
||||||
|
style=single-quoted-argument
|
||||||
|
else
|
||||||
|
style=single-quoted-argument-unclosed
|
||||||
|
fi
|
||||||
|
highlights+=($(( start_pos + $1 - 1 )) $(( start_pos + i )) $style $highlights)
|
||||||
_zsh_highlight_main_add_many_region_highlights $highlights
|
_zsh_highlight_main_add_many_region_highlights $highlights
|
||||||
REPLY=$i
|
REPLY=$i
|
||||||
}
|
}
|
||||||
@ -912,7 +921,12 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
|
|||||||
highlights+=($j $k $style)
|
highlights+=($j $k $style)
|
||||||
done
|
done
|
||||||
|
|
||||||
highlights=($(( start_pos + $1 - 1)) $(( start_pos + i )) double-quoted-argument $highlights)
|
if [[ $arg[i] == '"' ]]; then
|
||||||
|
style=double-quoted-argument
|
||||||
|
else
|
||||||
|
style=double-quoted-argument-unclosed
|
||||||
|
fi
|
||||||
|
highlights=($(( start_pos + $1 - 1)) $(( start_pos + i )) $style $highlights)
|
||||||
_zsh_highlight_main_add_many_region_highlights $highlights
|
_zsh_highlight_main_add_many_region_highlights $highlights
|
||||||
REPLY=$i
|
REPLY=$i
|
||||||
}
|
}
|
||||||
@ -959,7 +973,12 @@ _zsh_highlight_main_highlighter_highlight_dollar_quote()
|
|||||||
highlights+=($j $k $style)
|
highlights+=($j $k $style)
|
||||||
done
|
done
|
||||||
|
|
||||||
highlights=($(( start_pos + $1 - 1 )) $(( start_pos + i )) dollar-quoted-argument $highlights)
|
if [[ $arg[i] == "'" ]]; then
|
||||||
|
style=dollar-quoted-argument
|
||||||
|
else
|
||||||
|
style=dollar-quoted-argument-unclosed
|
||||||
|
fi
|
||||||
|
highlights+=($(( start_pos + $1 - 1 )) $(( start_pos + i )) $style $highlights)
|
||||||
_zsh_highlight_main_add_many_region_highlights $highlights
|
_zsh_highlight_main_add_many_region_highlights $highlights
|
||||||
REPLY=$i
|
REPLY=$i
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,6 @@
|
|||||||
BUFFER=": \$'\xa1"
|
BUFFER=": \$'\xa1"
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"3 4 dollar-quoted-argument" # $'
|
"3 4 dollar-quoted-argument-unclosed" # $'
|
||||||
"5 8 back-dollar-quoted-argument" # \xa1
|
"5 8 back-dollar-quoted-argument" # \xa1
|
||||||
)
|
)
|
||||||
|
@ -32,6 +32,6 @@
|
|||||||
BUFFER=': "foo$bar'
|
BUFFER=': "foo$bar'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"3 6 double-quoted-argument" # "foo
|
"3 6 double-quoted-argument-unclosed" # "foo
|
||||||
"7 10 dollar-double-quoted-argument" # $bar
|
"7 10 dollar-double-quoted-argument" # $bar
|
||||||
)
|
)
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
BUFFER=$'echo "foo1\n'
|
BUFFER=$'echo \'foo1\n'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"6 10 double-quoted-argument" # 'foo2"'
|
"6 10 single-quoted-argument-unclosed" # 'foo1
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user