From 594f2ff06e85bf27b154dd703ee3b2dd7f168bc0 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Thu, 7 Jun 2018 17:48:48 +0200 Subject: users/23434: initialise UNDO_LIMIT_NO so that an initial undo doesn't clear the whole edit buffer --- Functions/Misc/zed | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Functions') diff --git a/Functions/Misc/zed b/Functions/Misc/zed index 56fdef188..9eb4b2d93 100644 --- a/Functions/Misc/zed +++ b/Functions/Misc/zed @@ -72,6 +72,12 @@ if (( bind )) || ! bindkey -M zed >&/dev/null; then # zed we may want to set this temporally. bindkey -A main zed-normal-keymap + # Define a widget to use at startup, undo shouldn't clear initial buffer + __zed_init() { + UNDO_LIMIT_NO=$UNDO_CHANGE_NO + } + zle -N __zed_init + # Assign some default keys. # Depending on your stty's, you may be able to use ^J as accept-line, else: @@ -126,11 +132,11 @@ if ((fun)) then var="${(q-)1} () { }" fi - vared -M zed -m zed-vicmd var && eval function "$var" + vared -M zed -m zed-vicmd -i __zed_init var && eval function "$var" else zed_file_name=$1 [[ -f $1 ]] && var="$(<$1)" - while vared -M zed -m zed-vicmd var + while vared -M zed -m zed-vicmd -i __zed_init var do { print -r -- "$var" >| $zed_file_name -- cgit 1.4.1