1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-17 13:36:04 +02:00

52082: Enable linewise edit-command when in visual-line mode.

This commit is contained in:
Christoffer Lundell 2023-09-16 20:06:12 -07:00 committed by Bart Schaefer
parent 293d36ae1e
commit f72757ccf3
2 changed files with 22 additions and 4 deletions

View File

@ -1,5 +1,8 @@
2023-09-16 Bart Schaefer <schaefer@zsh.org>
* Christoffer Lundell: 52082: Functions/Zle/edit-command-line:
Enable linewise edit-command when in visual-line mode.
* 52155: Test/D10nofork.ztst: Tests for non-forking substitution.
* 52154: Doc/Zsh/expn.yo, Src/lex.c, Src/subst.c: implement

View File

@ -11,15 +11,30 @@ local left right prebuffer buffer=$BUFFER lbuffer=$LBUFFER
local TMPSUFFIX=.zsh
# set up parameters depending on which context we are called from,
# see below comment for more details
if (( REGION_ACTIVE )); then
if (( REGION_ACTIVE == 1 )); then
if (( CURSOR < MARK )); then
left=$CURSOR right=$MARK
lbuffer=
else
left=$MARK right=$CURSOR
lbuffer[right-left,-1]=
fi
(( left++ ))
lbuffer=$lbuffer[++left,-1]
buffer=$BUFFER[left,++right]
elif (( REGION_ACTIVE == 2 )); then
local nl=$'\n'
if (( CURSOR < MARK )); then
left=${${BUFFER[1,CURSOR]}[(I)$nl]}
right=${${BUFFER[MARK+1,-1]}[(i)$nl]}
(( right += MARK ))
else
left=${${BUFFER[1,MARK]}[(I)$nl]}
right=${${BUFFER[CURSOR+1,-1]}[(i)$nl]}
(( right += CURSOR ))
fi
lbuffer=$lbuffer[++left,-1]
if [[ $BUFFER[right] = $nl ]]; then
# Keep the newline because "$(<$1)" below trims it
(( --right ))
fi
buffer=$BUFFER[left,right]
elif (( ! ZLE_RECURSIVE )); then
prebuffer=$PREBUFFER