summaryrefslogtreecommitdiff
path: root/Functions/Zle/edit-command-line
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@fairlystable.org>2025-04-30 02:07:56 -0700
committerJoe Rayhawk <jrayhawk@fairlystable.org>2025-04-30 02:07:56 -0700
commit26e09889646be3ea65b4a3dfeda26213e4bb6a27 (patch)
tree4f3c73a9416bf47ad7e125383d23cf42879e38d7 /Functions/Zle/edit-command-line
parent841bce705a58b04220b1f257abcc00ae71cbdbdc (diff)
parent001cba48ce3b964cf01fb3e2af54b20eacbc9bf5 (diff)
downloadzsh-26e09889646be3ea65b4a3dfeda26213e4bb6a27.tar.gz
zsh-26e09889646be3ea65b4a3dfeda26213e4bb6a27.zip
Merge branch 'upstream' into debian
Diffstat (limited to 'Functions/Zle/edit-command-line')
-rw-r--r--Functions/Zle/edit-command-line23
1 files changed, 19 insertions, 4 deletions
diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
index 5f7ea321f..d4b405eaf 100644
--- a/Functions/Zle/edit-command-line
+++ b/Functions/Zle/edit-command-line
@@ -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