Highlight the region and yanks and pastes on top of syntax highlighting.
Fixes zsh-users/zsh-syntax-highlighting#165. Fixes zsh-users/zsh-syntax-highlighting#175. * danielsh/i165-region-v1: Highlight yanks/pastes on top of syntax highlighting. Highlight the region on top of syntax highlighting.
This commit is contained in:
commit
51102bf83f
|
@ -92,6 +92,37 @@ _zsh_highlight()
|
|||
|
||||
done
|
||||
|
||||
# Re-apply zle_highlight settings
|
||||
() {
|
||||
if (( REGION_ACTIVE )) ; then
|
||||
# zle_highlight[region] defaults to 'standout' if unspecified
|
||||
local region="${${zle_highlight[(r)region:*]#region:}:-standout}"
|
||||
integer start end
|
||||
if (( MARK > CURSOR )) ; then
|
||||
start=$CURSOR end=$MARK
|
||||
else
|
||||
start=$MARK end=$CURSOR
|
||||
fi
|
||||
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 {
|
||||
_ZSH_HIGHLIGHT_PRIOR_BUFFER=$BUFFER
|
||||
_ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR
|
||||
|
|
Loading…
Reference in New Issue