invert-below command to substitute for visual mode (#1101)

This command inverts the selection for the current file and all the files below
it. Using this command twice substitutes for having a "visual" mode. This is
described in more detail in the docs and in
https://github.com/gokcehan/lf/issues/477#issuecomment-1414563834.

Fixes #477. While that's not exactly what was asked for, I hope it's a suitable
replacement and seems more in the spirit of `lf`, at least until a better
replacement is implemented.
This commit is contained in:
Ilya Grigoriev authored and GitHub committed 2023-02-26 01:00:54 +03:00
1 parent 752f059068
commit b02fd42df4
6 files changed
+54 -2

No files matched your search

+10 -2
View File
@@ -1149,14 +1149,22 @@ func (nav *nav) tag(tag string) error {
return nil
}
func (nav *nav) invert() {
func (nav *nav) invertAfter(ix int) {
dir := nav.currDir()
for _, f := range dir.files {
for _, f := range dir.files[ix:] {
path := filepath.Join(dir.path, f.Name())
nav.toggleSelection(path)
}
}
func (nav *nav) invert() {
nav.invertAfter(0)
}
func (nav *nav) invertBelow() {
nav.invertAfter(nav.currDir().ind)
}
func (nav *nav) unselect() {
nav.selections = make(map[string]int)
nav.selectionInd = 0