Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: edit-command-line breaks out of vared



On Sun, Aug 19, 2018 at 2:22 PM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> [[[
> $ zsh -f
> % l=( 1 2 3  )
> % bindkey -e
> % autoload edit-command-line
> % zle -N edit-command-line
> % bindkey '^Fc' edit-command-line
> % vared l
> <press ^F c>
> <:w>
> <:q>
> % 1 2 3<CURSOR>
> ]]]
>
> I expected quitting the editor to let me resume the vared session, but
> instead it left me with the variable's value as a command line.

This works in my version of edit-command-line,

diff --git c/Functions/Zle/edit-command-line w/Functions/Zle/edit-command-line
index e17893e938..761f8da6d0 100644
--- c/Functions/Zle/edit-command-line
+++ w/Functions/Zle/edit-command-line
@@ -29,7 +29,12 @@
   (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[1]

   # Replace the buffer with the editor output.
-  print -Rz - "$(<$1)"
-} =(<<<"$PREBUFFER$BUFFER")
+  # avoid drawing a new prompt when we can
+  [[ -z $PREBUFFER ]] && {
+    BUFFER="$(<$1)"
+  } || {
+    print -Rz - "$(<$1)"
+    zle send-break
+  }

-zle send-break         # Force reload from the buffer stack
+} =(<<<"$PREBUFFER$BUFFER")


-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author