|
2 | 2 | # Copyright (c) 2018 Sebastian Gniazdowski |
3 | 3 | # |
4 | 4 | # Chroma function for command `perl'. It highlights code passed to perl |
5 | | -# with -e option - does syntax check by calling `perl -ce', then highlights |
6 | | -# as correct or incorrect code. |
| 5 | +# with -e or -E option - does syntax check by calling `perl -ce' or `perl -cE', |
| 6 | +# then highlights as correct or incorrect code. |
7 | 7 | # |
8 | 8 | # $1 - 0 or 1, denoting if it's first call to the chroma, or following one |
9 | 9 | # $2 - the current token, also accessible by $__arg from the above scope - |
@@ -43,20 +43,30 @@ integer __idx1 __idx2 |
43 | 43 |
|
44 | 44 | if [[ "$__wrd" = "-e" || ("$__wrd" = -*e* && "$__wrd" != --*) ]]; then |
45 | 45 | FAST_HIGHLIGHT[chrome-perl-got-eswitch]=1 |
| 46 | + elif [[ "$__wrd" = "-E" || ("$__wrd" = -*E* && "$__wrd" != --*) ]]; then |
| 47 | + FAST_HIGHLIGHT[chrome-perl-got-eswitch]=2 |
46 | 48 | fi |
47 | 49 | else |
48 | 50 | __wrd="${__wrd//\`/x}" |
49 | 51 | __arg="${__arg//\`/x}" |
50 | 52 | __wrd="${(Q)__wrd}" |
51 | | - if (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] == 1 )); then |
52 | | - FAST_HIGHLIGHT[chrome-perl-got-eswitch]=0 |
53 | | - if perl -ce "$__wrd" >/dev/null 2>&1; then |
54 | | - # Add correct-subtle style |
55 | | - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") |
56 | | - else |
57 | | - # Add incorrect-subtle style |
58 | | - (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") |
| 53 | + |
| 54 | + if (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] )); then |
| 55 | + if (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )); then |
| 56 | + if (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] == 1 )); then |
| 57 | + perl -ce "$__wrd" >/dev/null 2>&1 |
| 58 | + elif (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] == 2 )); then |
| 59 | + perl -cE "$__wrd" >/dev/null 2>&1 |
| 60 | + fi && { |
| 61 | + # Add correct-subtle style |
| 62 | + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}") |
| 63 | + } || { |
| 64 | + # Add incorrect-subtle style |
| 65 | + reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}") |
| 66 | + } |
59 | 67 | fi |
| 68 | + |
| 69 | + FAST_HIGHLIGHT[chrome-perl-got-eswitch]=0 |
60 | 70 | else |
61 | 71 | # Pass-through to the big-loop outside |
62 | 72 | return 1 |
|
0 commit comments