File tree 3 files changed +10
-1
lines changed
3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ This highlighter defines the following styles:
56
56
* ` dollar-quoted-argument-unclosed ` - unclosed dollar-quoted arguments (`` $'foo `` )
57
57
* ` rc-quote ` - two single quotes inside single quotes when the ` RC_QUOTES ` option is set (`` 'foo''bar' `` )
58
58
* ` dollar-double-quoted-argument ` - parameter expansion inside double quotes (` $foo ` inside ` "" ` )
59
+ * ` back-un-quoted-argument ` - backslash escape sequences outside quotes (` \" ` in ` print -r \"bar\" ` )
59
60
* ` back-double-quoted-argument ` - backslash escape sequences inside double-quoted arguments (` \" ` in ` "foo\"bar" ` )
60
61
* ` back-dollar-quoted-argument ` - backslash escape sequences inside dollar-quoted arguments (` \x ` in ` $'\x48' ` )
61
62
* ` assign ` - parameter assignments (` x=foo ` and ` x=( ) ` )
Original file line number Diff line number Diff line change 55
55
: ${ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]:= fg=yellow}
56
56
: ${ZSH_HIGHLIGHT_STYLES[rc-quote]:= fg=cyan}
57
57
: ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:= fg=cyan}
58
+ : ${ZSH_HIGHLIGHT_STYLES[back-un-quoted-argument]:= fg=cyan}
58
59
: ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:= fg=cyan}
59
60
: ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:= fg=cyan}
60
61
: ${ZSH_HIGHLIGHT_STYLES[assign]:= none}
@@ -1328,7 +1329,13 @@ _zsh_highlight_main_highlighter_highlight_argument()
1328
1329
i=${arg[(ib.i.)[\\\'\"\`\$\<\>\*\?]]}
1329
1330
case " $arg [$i ]" in
1330
1331
" " ) break ;;
1331
- " \\ " ) (( i += 1 )) ; continue ;;
1332
+ " \\ " )
1333
+ highlights+=(
1334
+ $(( start_pos + i - 1 )) $(( start_pos + i + 1 )) back-un-quoted-argument
1335
+ )
1336
+ (( i += 1 ))
1337
+ continue
1338
+ ;;
1332
1339
" '" )
1333
1340
_zsh_highlight_main_highlighter_highlight_single_quote $i
1334
1341
(( i = REPLY ))
Original file line number Diff line number Diff line change @@ -34,4 +34,5 @@ expected_region_highlight=(
34
34
' 1 4 builtin' # echo
35
35
' 6 18 default "issue #705"' # foo\\\nbar"baz"
36
36
' 14 18 double-quoted-argument "issue #705"' # "baz"
37
+ # TODO: when fixing this, see if we can highlight the backslash-newline sequence as a comment.
37
38
)
You can’t perform that action at this time.
0 commit comments