fix: advance cursor during cmd-transpose (#2413)
* fix: advance cursor during `cmd-transpose` * Update `CHANGELOG.md`
This commit is contained in:
1 parent
1afe4ff441
commit
0bbeae73df
5 files changed
+47
-11
No files matched your search
@@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
- The `on-load` hook command now ignores `.git` directories to reduce flicker and repeated `on-load` triggers (#2382).
|
||||
- Preview messages like `empty` or `loading...` have their alignment improved (#2400).
|
||||
- A bug where the `loading...` message was not displayed for volatile previews after the first time is now fixed (#2410).
|
||||
- The `cmd-transpose` command now advances the cursor correctly after swapping characters (#2413).
|
||||
|
||||
## [r41](https://github.com/gokcehan/lf/releases/tag/r41)
|
||||
|
||||
|
||||
@@ -811,9 +811,15 @@ Delete the previous Unix word.
|
||||
|
||||
Paste the buffer content containing the last deleted item.
|
||||
|
||||
## cmd-transpose (default `<c-t>`), cmd-transpose-word (default `<a-t>`)
|
||||
## cmd-transpose (default `<c-t>`)
|
||||
|
||||
Transpose the positions of the last two characters/words.
|
||||
Swap the characters before and after the cursor, then move the cursor forward.
|
||||
If there is no character after the cursor, swap the previous two characters instead.
|
||||
|
||||
## cmd-transpose-word (default `<a-t>`)
|
||||
|
||||
Swap the words before and after the cursor, then move the cursor forward.
|
||||
If there is no word after the cursor, swap the previous two words instead.
|
||||
|
||||
## cmd-word (default `<a-f>`), cmd-word-back (default `<a-b>`)
|
||||
|
||||
|
||||
@@ -862,9 +862,17 @@ cmd-yank (default <c-y>)
|
||||
|
||||
Paste the buffer content containing the last deleted item.
|
||||
|
||||
cmd-transpose (default <c-t>), cmd-transpose-word (default <a-t>)
|
||||
cmd-transpose (default <c-t>)
|
||||
|
||||
Transpose the positions of the last two characters/words.
|
||||
Swap the characters before and after the cursor, then move the cursor
|
||||
forward. If there is no character after the cursor, swap the previous
|
||||
two characters instead.
|
||||
|
||||
cmd-transpose-word (default <a-t>)
|
||||
|
||||
Swap the words before and after the cursor, then move the cursor
|
||||
forward. If there is no word after the cursor, swap the previous two
|
||||
words instead.
|
||||
|
||||
cmd-word (default <a-f>), cmd-word-back (default <a-b>)
|
||||
|
||||
|
||||
@@ -1978,12 +1978,25 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
app.ui.cmdAccLeft += app.ui.cmdYankBuf
|
||||
update(app)
|
||||
case "cmd-transpose":
|
||||
r := []rune(app.ui.cmdAccLeft)
|
||||
if len(r) < 2 {
|
||||
var c []string
|
||||
gr := uniseg.NewGraphemes(app.ui.cmdAccLeft)
|
||||
for gr.Next() {
|
||||
c = append(c, gr.Str())
|
||||
}
|
||||
|
||||
first := firstGraphemeCluster(app.ui.cmdAccRight)
|
||||
if first != "" {
|
||||
c = append(c, first)
|
||||
}
|
||||
|
||||
if len(c) < 2 {
|
||||
return
|
||||
}
|
||||
r[len(r)-1], r[len(r)-2] = r[len(r)-2], r[len(r)-1]
|
||||
app.ui.cmdAccLeft = string(r)
|
||||
|
||||
app.ui.cmdAccRight = strings.TrimPrefix(app.ui.cmdAccRight, first)
|
||||
|
||||
c[len(c)-1], c[len(c)-2] = c[len(c)-2], c[len(c)-1]
|
||||
app.ui.cmdAccLeft = strings.Join(c, "")
|
||||
update(app)
|
||||
case "cmd-transpose-word":
|
||||
if app.ui.cmdAccLeft == "" {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.\" Automatically generated by Pandoc 3.7.0.2
|
||||
.\"
|
||||
.TH "LF" "1" "2026\-02\-28" "r41" "DOCUMENTATION"
|
||||
.TH "LF" "1" "2026\-03\-04" "r41" "DOCUMENTATION"
|
||||
.SH NAME
|
||||
lf \- terminal file manager
|
||||
.SH SYNOPSIS
|
||||
@@ -783,8 +783,16 @@ Delete everything up to the beginning/end of the line.
|
||||
Delete the previous Unix word.
|
||||
.SS cmd\-yank (default \f[CR]<c\-y>\f[R])
|
||||
Paste the buffer content containing the last deleted item.
|
||||
.SS cmd\-transpose (default \f[CR]<c\-t>\f[R]), cmd\-transpose\-word (default \f[CR]<a\-t>\f[R])
|
||||
Transpose the positions of the last two characters/words.
|
||||
.SS cmd\-transpose (default \f[CR]<c\-t>\f[R])
|
||||
Swap the characters before and after the cursor, then move the cursor
|
||||
forward.
|
||||
If there is no character after the cursor, swap the previous two
|
||||
characters instead.
|
||||
.SS cmd\-transpose\-word (default \f[CR]<a\-t>\f[R])
|
||||
Swap the words before and after the cursor, then move the cursor
|
||||
forward.
|
||||
If there is no word after the cursor, swap the previous two words
|
||||
instead.
|
||||
.SS cmd\-word (default \f[CR]<a\-f>\f[R]), cmd\-word\-back (default \f[CR]<a\-b>\f[R])
|
||||
Move the cursor by one word in the forward/backward direction.
|
||||
.SS cmd\-delete\-word (default \f[CR]<a\-d>\f[R])
|
||||
|
||||
Reference in new issue
Block a user