summaryrefslogtreecommitdiff
path: root/Functions/Zle/bracketed-paste-magic
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/Zle/bracketed-paste-magic')
-rw-r--r--Functions/Zle/bracketed-paste-magic29
1 files changed, 12 insertions, 17 deletions
diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic
index 464c6b339..2b2bc630d 100644
--- a/Functions/Zle/bracketed-paste-magic
+++ b/Functions/Zle/bracketed-paste-magic
@@ -116,10 +116,14 @@ quote-paste() {
# Now the actual function
bracketed-paste-magic() {
- # Fast exit in the vi-mode cut-buffer context
if [[ "$LASTWIDGET" = *vi-set-buffer ]]; then
+ # Fast exit in the vi-mode cut-buffer context
zle .bracketed-paste
return
+ else
+ # Capture the pasted text in $PASTED
+ local PASTED REPLY
+ zle .bracketed-paste PASTED
fi
# Really necessary to go to this much effort?
@@ -127,10 +131,9 @@ bracketed-paste-magic() {
emulate -L zsh
local -a bpm_hooks bpm_inactive
- local PASTED bpm_func bpm_active bpm_keymap=$KEYMAP
+ local bpm_func bpm_active bpm_keymap=$KEYMAP
- # Set PASTED and run the paste-init functions
- zle .bracketed-paste PASTED
+ # Run the paste-init functions
if zstyle -a :bracketed-paste-magic paste-init bpm_hooks; then
for bpm_func in $bpm_hooks; do
if (( $+functions[$bpm_func] )); then
@@ -164,25 +167,17 @@ bracketed-paste-magic() {
integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO
UNDO_LIMIT_NO=$UNDO_CHANGE_NO
- local mbchar
- integer ismb
while [[ -n $PASTED ]] && zle .read-command; do
- mbchar=$KEYS
- ismb=0
- while [[ $mbchar = [[:INCOMPLETE:]]* ]] && zle .read-command; do
- mbchar+=$KEYS
- ismb=1
- done
- PASTED=${PASTED#$mbchar}
- if [[ ismb -ne 0 || $mbchar = ${(~j:|:)${(b)bpm_inactive}} ]]; then
- LBUFFER+=$mbchar
+ PASTED=${PASTED#$KEYS}
+ if [[ $KEYS = ${(~j:|:)${(b)bpm_inactive}} ]]; then
+ zle .self-insert
else
case $REPLY in
(${~bpm_active}) function () {
emulate -L $bpm_emulate; set -$bpm_opts
zle $REPLY
};;
- (*) LBUFFER+=$mbchar;
+ (*) zle .self-insert;;
esac
fi
done
@@ -221,7 +216,7 @@ bracketed-paste-magic() {
zle .split-undo
# Arrange to display highlighting if necessary
- if [[ -n ${(M)zle_highlight:#paste:*} ]]; then
+ if [[ -z $zle_highlight || -n ${(M)zle_highlight:#paste:*} ]]; then
zle -R
zle .read-command && zle -U - $KEYS
fi