jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
18.51k stars 743 forks source link

avoid cursor jump when file under cursor is renamed by plugin/`r` #1869

Closed azuline closed 2 months ago

azuline commented 2 months ago

This PR prevents the cursor from jumping back to the top of the directory when the active file (file underneath the cursor) is renamed by the r renamer tool or an external plugin.

https://github.com/jarun/nnn/assets/51880422/a98d56c8-68ec-4570-80d3-e7d74c15860a

My use case:

I use nnn to navigate my music library, with a custom plugin to operate on music directories. Several of these commands rename the directory. Currently, once the directory is renamed (often the change of a single character), the cursor jumps back to the top of the working directory, requiring me to navigate back to where I was in a fairly large directory. After this change, the cursor no longer jumps.

jarun commented 2 months ago

Currently, once the directory is renamed (often the change of a single character)

From the nnn help page:

^R Rename/dup r Batch rename

If you are changing only 1 file/dir, use ^R.

Alternatively, use filters to reach a file quickly. Since you have just renamed it, you should be knowing the name.

azuline commented 2 months ago

I am neither using ^R or r, but a custom plugin in a very large directory. I will keep this behavior in a fork since it is only important to my use case. 👍🏼