mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
35769: edit-command-line: Go to the right byte offset
This commit is contained in:
parent
5911aca85f
commit
35ffe36318
2 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2015-07-13 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* 35769: Functions/Zle/edit-command-line: edit-command-line:
|
||||
Go to the right byte offset
|
||||
|
||||
2015-07-13 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 35737: (tweaked c.f. Peter: 35759): Src/Zle/zle_utils.c,
|
||||
|
|
|
@ -8,7 +8,17 @@
|
|||
|
||||
() {
|
||||
exec </dev/tty
|
||||
${=${VISUAL:-${EDITOR:-vi}}} $1
|
||||
|
||||
# Open the editor, placing the cursor at the right place if we know how.
|
||||
local editor=${${VISUAL:-${EDITOR:-vi}}}
|
||||
integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
|
||||
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")
|
||||
|
||||
|
|
Loading…
Reference in a new issue