ranger icon indicating copy to clipboard operation
ranger copied to clipboard

Changed scout <tab> to cycle through files even when pattern is empty

Open nadapez opened this issue 3 years ago • 0 comments

ISSUE TYPE

  • Improvement/feature implementation

RUNTIME ENVIRONMENT

CHECKLIST

  • [x] The CONTRIBUTING document has been read [REQUIRED]
  • [x] All changes follow the code style [REQUIRED]
  • [x] All new and existing tests pass [REQUIRED]
  • [ ] Changes require config files to be updated
    • [ ] Config files have been updated
  • [ ] Changes require documentation to be updated
    • [ ] Documentation has been updated
  • [ ] Changes require tests to be updated
    • [ ] Tests have been updated

DESCRIPTION

This changes the behavior of scout command when <tab> is pressed in the console and the pattern is empty.

Currently when the pattern is empty pressing <tab> does nothing.

With this change, pressing <tab> cycles the pointer through all the files in the current view.

The changes in the code (scout._count) are these:

split the conditional:

if not cwd.files or not pattern:
    return 0

into these two:

if not cwd.files:
    return 0
if not pattern:
    cwd.move(to=(cwd.pointer + offset) % len(cwd.files))
    self.fm.thisfile = cwd.pointed_obj
    return 0

These only changes the behavior when there are files in the current dir and there is no pattern. In such case the pointer is moved according to offset, which is only non zero if tab or shift tab was pressed.

If offset is zero (tab was not pressed) then the pointer is moved by 0 (is not moved), and the next line is dummy.

MOTIVATION AND CONTEXT

Fix #2575

TESTING

IMAGES / VIDEOS

nadapez avatar Sep 17 '22 16:09 nadapez