From 3594f55fc087c1272ec4a4f15f17dfb007a226ec Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Tue, 6 Dec 2016 21:37:30 -0800 Subject: 40115: revert 38579 due to bug restoring BUFFER after history search This reverts commit 20948d088994dc7b26a26b94926432985fa6863e. --- ChangeLog | 3 +++ Functions/Zle/bracketed-paste-magic | 44 +++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8ec83337c..61c4c12d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-12-06 Barton E. Schaefer + * Zhiming Wang: 40115: Functions/Zle/bracketed-paste-magic: + revert 38579 due to bug restoring BUFFER after history search + * 40110: Test/B02typeset.ztst: ignore strerror text in test output, it differs by OS diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic index fb584d595..c46f741d5 100644 --- a/Functions/Zle/bracketed-paste-magic +++ b/Functions/Zle/bracketed-paste-magic @@ -145,26 +145,27 @@ bracketed-paste-magic() { done fi + # Save context, create a clean slate for the paste + integer bpm_mark=$MARK bpm_cursor=$CURSOR bpm_region=$REGION_ACTIVE + integer bpm_numeric=${NUMERIC:-1} + local bpm_buffer=$BUFFER + fc -p -a /dev/null 0 0 + BUFFER= + zstyle -a :bracketed-paste-magic inactive-keys bpm_inactive if zstyle -s :bracketed-paste-magic active-widgets bpm_active '|'; then - # Save context, create a clean slate for the paste - integer bpm_mark=$MARK bpm_region=$REGION_ACTIVE - integer bpm_numeric=${NUMERIC:-1} - integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO - BUFFER= - CURSOR=1 - zle .split-undo - UNDO_LIMIT_NO=$UNDO_CHANGE_NO - fc -p -a /dev/null 0 0 + # There are active widgets. Reprocess $PASTED as keystrokes. + NUMERIC=1 + zle -U - $PASTED + if [[ $bmp_keymap = vicmd ]]; then zle -K viins fi - # There are active widgets. Reprocess $PASTED as keystrokes. - NUMERIC=1 - zle -U - "$PASTED" - # Just in case there are active undo widgets + zle .split-undo + integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO + UNDO_LIMIT_NO=$UNDO_CHANGE_NO while [[ -n $PASTED ]] && zle .read-command; do PASTED=${PASTED#$KEYS} @@ -182,16 +183,21 @@ bracketed-paste-magic() { done PASTED=$BUFFER - # Restore state - zle -K $bpm_keymap - fc -P - MARK=$bpm_mark - REGION_ACTIVE=$bpm_region - NUMERIC=$bpm_numeric + # Reset the undo state zle .undo $bpm_undo UNDO_LIMIT_NO=$bpm_limit + + zle -K $bpm_keymap fi + # Restore state + BUFFER=$bpm_buffer + MARK=$bpm_mark + CURSOR=$bpm_cursor + REGION_ACTIVE=$bpm_region + NUMERIC=$bpm_numeric + fc -P + # PASTED has been updated, run the paste-finish functions if zstyle -a :bracketed-paste-magic paste-finish bpm_hooks; then for bpm_func in $bpm_hooks; do -- cgit 1.4.1