Simplify logic in ui.go. In that diff, `st` would already have the
Reversed flag set; there's no need to set it again.
Also, minor changes to remove all the statickcheck errors VS code's
Go extension complains about.
# What this does
This makes the following changes:
1. If the we are in any of the shell command-line modes (after pressing one of
`!/$/%/&`) and the cursor is at the first character, pressing `backspace`
switches you to the `:` mode. Pressing `backspace` again will take you out of
the command-line mode as before (this commit extends the recent [escape on
backspace] functionality).
[escape on backspace]: https://github.com/gokcehan/lf/commit/36a7a18316580864f2f2ebd79e9ddae4858f6b60
2. Conversely, if we are in the `:` mode and the cursor is at the first
character, pressing one of `!/$/%/&` will take you to the corresponding mode
insted of inserting that character. This is a very minor change, since already
pressing `:!ls<ret>` and `!ls <ret>` in `lf` has the same effect. After this
commit, these will also look the same even before pressing `<ret>`.
3. There is a minor bugfix to the [escape on backspace] commit. In `>` mode
(when a program launched with `&` waits for input), `lf` currently switches to
normal mode on `backspace` without terminating the program. After this commit,
the "escape on backspace" functionality is disabled in `>` mode.
This idea is borrowed from the [Julia REPL modes].
[Julia REPL modes]: https://docs.julialang.org/en/v1/stdlib/REPL/#Help-mode
# What problems this solves
The main problem I want to solve is that I often type `$ls <many options>` and
realize I wanted `!ls` all along. Currently, there is no easy way to switch.
With this commit, it becomes trivial.
This problem also occurs when you scroll up to a `$ls <many options>` command
in history.
Finally, since `!` and `:!` have essentially the same effect in `lf`, I think
they should look the same.
- Clean up some code duplication.
- When completing files with menu completion while searching, don't
escape the selected match.
- Don't recompute completions while cycling completion menu.
* Revert escaping changes from cb7aa13
The changes introduced a bug where escapes were removed when there are
no completion matches.
* Add option to ignore case in filename completion
* Remove compignorecase option and hardcode it
* Get command default count from definition
The command count defined in opts.go will be respected. In order to do that a copy of the callExpr or listExpr command is created so that the defined count is not overridden.
* Copy the command only if we need to overwrite the count
* Directory previews, initial implementation.
* Continue previous; add goroutine for directory previews.
* Enable dirpreviews as an option, run gofmt and fix referencing nil.
* Only use dirpreviews if previewer script exists.
* Remove redundant function call to `dirPreview`.
* Remove unnecessary dev-comments.
* Send to `dirPreviewChan` also on modifying folder contents.
Previously the history position was only reset when executing the
history prev/next command in normal mode, so it was not reset if you
entered command-line mode then started moving through the history.
This fixes an issue where if you stared a search then deleted the search
text (with e.g. backspace) it would perform a search for the empty
string and move the selection to the next file.
* Fix some multibyte character completion bugs
- matchLongest now operates on runes instead of bytes so we don't
complete part of a multibyte character.
- Fix some places that mixed string and rune slice indices.
* Fix wrong menu completion for subdirectories
When selecting a menu completion for a file in a subdirectory, the
entire filename would be appended to the command line, even if you had
already typed part of it.
* Escape file completions in menu completion
* Minor refactors and typo fixes
* Fix cmd-menu-complete-back bug
The first use of cmd-menu-complete-back after opening the completion
menu was incorrectly selecting the before-last completion instead of the
last completion.
* Allow completing broken symlinks
Also skip files with stat errors instead of returning.
* Add command to accept current menu selection
This is useful when completing filenames. For example
cmap <c-y> :cmd-menu-accept; cmd-menu-complete
can be used to accept the selected directory completion, then complete
files in the directory.
* Complete command names for map and cmap
- Document history option
- Use $() command substitution syntax because backticks are replaced
with quotes in gen/docstring.sh
- Movement commands no longer close the search prompt (85aa3b9)
- Use the -L flag of the file command instead of readlink
* initial tags implementation
* add tag to complete.go
* add gTagsPath to os_windows.go
* change behaviour to match other commands
* add tag-toggle to complete.go
* add tag and tag-toggle to docs
* address feedback about tags