diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2015-08-22 01:55:58 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2015-08-22 01:55:58 +0200 |
commit | 02f6e25bfcd5feb9a093377dda0dd549cdf5c309 (patch) | |
tree | 9a25e61122b3fa0d0a1ff68b5ef05c775ff78b1e /Functions/Zle/edit-command-line | |
parent | e04a19735ffc8523b93b33074f685ad4e2c92e0c (diff) | |
parent | 881474edcb223ac22a08d81a824809c33ca3a9c9 (diff) | |
download | zsh-02f6e25bfcd5feb9a093377dda0dd549cdf5c309.tar.gz zsh-02f6e25bfcd5feb9a093377dda0dd549cdf5c309.zip |
Merge tag 'zsh-5.0.8-test-2' into debian
Diffstat (limited to 'Functions/Zle/edit-command-line')
-rw-r--r-- | Functions/Zle/edit-command-line | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line index 100af9601..2c7f34b8b 100644 --- a/Functions/Zle/edit-command-line +++ b/Functions/Zle/edit-command-line @@ -8,7 +8,20 @@ () { exec </dev/tty - ${=${VISUAL:-${EDITOR:-vi}}} $1 + + # Compute the cursor's position in bytes, not characters. + setopt localoptions nomultibyte + integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 )) + + # Open the editor, placing the cursor at the right place if we know how. + local editor=${${VISUAL:-${EDITOR:-vi}}} + case $editor in + (*vim*) ${=editor} -c "normal! ${byteoffset}go" -- $1;; + (*emacs*) ${=editor} $1 -eval "(goto-char ${byteoffset})";; + (*) ${=editor} $1;; + esac + + # Replace the buffer with the editor output. print -Rz - "$(<$1)" } =(<<<"$PREBUFFER$BUFFER") |