dired-hacks icon indicating copy to clipboard operation
dired-hacks copied to clipboard

dired-narrow moves the cursor unnecessarily in dired buffer

Open geza-herman opened this issue 2 years ago • 0 comments

If adding a new character at the filter prompt creates a string, which matches both the current and the next line in the dired buffer, the cursor will move down in the dired buffer.

Repro: create an empty directory, and put files there named aaaaaaa1, aaaaaaa2, aaaaaaa3, aaaaaaa4. Now, start dired in this directory, run dired-narrow, and type the string aaaaaaa at the Filter: prompt. Notice, that each press of a will move the cursor down in the dired buffer. If the cursor reaches the bottom, it will move upwards once, and then move downwards again. I expect that the cursor doesn't move if the currently selected dired entry still matches the filter.

I tried to fix this, and it seems to work if I add a condition at the bottom of dired-narrow--update (checks whether the cursor stands on an invisible line), but I'm not sure that this is a proper fix:

    (when (or (get-text-property (point) 'invisible) (not (dired-utils-is-file-p)))
      (unless (dired-hacks-next-file)
        (dired-hacks-previous-file))
      (unless (dired-utils-get-filename)
        (dired-hacks-previous-file)))

geza-herman avatar Jan 18 '22 11:01 geza-herman