From e5c2a88db023600d7aeacbb2b7d640e0c8671a83 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 8 Sep 2015 20:22:22 +0000 Subject: [PATCH] Highlight yanks/pastes on top of syntax highlighting. Let $zle_highlight[paste] override $region_highlight. --- zsh-syntax-highlighting.zsh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index e105a9f..012ea0b 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -106,6 +106,21 @@ _zsh_highlight() region_highlight+=("$start $end $region") fi } + # YANK_ACTIVE is only available in zsh-5.1.1 and newer + (( $+YANK_ACTIVE )) && () { + if (( YANK_ACTIVE )) ; then + # zle_highlight[paste] defaults to 'standout' if unspecified + local paste="${${zle_highlight[(r)paste:*]#paste:}:-standout}" + integer start end + if (( YANK_END > YANK_START )) ; then + start=$YANK_START end=$YANK_END + else + start=$YANK_END end=$YANK_START + fi + region_highlight+=("$start $end $paste") + fi + } + } always {