- Fixed anchor links (some links were not pointing to correct headings).
- Updated headings (some headings in outline didn't match the content).
- Fixed heading level for "Integrate with History" (was 2 should be 3).
* Delete unused code in `CircularCompletionHandler`
I could not find anywhere that the `Reedline::ActionHandler` event is
actually created, except for a bit of deserialization code in nushell
(reedline_config.rs:817). I suspect its functionality is no longer
needed in the current version of reedline.
* Improve word-level undo and completions undo
* Adds completions and history searches to the undo stack
This required changing all the menu interfaces to do their edits through
the `Editor` struct, so it can track undo state
* Improves the system of coalescing word-level edits on the undo stack
This involved expanding the `UndoBehavior` system. Now, every edit gets
tagged with `UndoBehavior`, and by comparing the `UndoBehavior` of the
current and previous edit, we can decide whether these changes should
be grouped together on the undo stack.
Chains of repeated backspace, delete, insertion, or history naviagition
can each be grouped together to form a single undo entry when
appropriate.
* Removing low-usage wrapper methods from editor.rs
Removes LineBuffer wrappers from Editor wherever the wrapper is used
only once, or only internally to the `editor.rs` file.
* Run cargo fmt
* Fixed undo coalescing for backspace/delete with \n
The logic was a bit trickier than I thought. Added some tests
to confirm the intended behavior where adding/deleting newlines creates
additional undo points
* Remove debugging logging code
* Revert "Removing low-usage wrapper methods from editor.rs"
- Also revert reintroduction of `CutFromStart` bug in vi mode
8b5e70fc0e
* Fix undo coalescing for CRLF deletions
* Ensure proper undo tracking in public Editor fns
Delete or make private all Editor functions that modify the line buffer
without tracking UndoBehavior
* Make Editor crate level pub
Added documentation for pub methods on Editor. Kept the public API
smaller by making many convenience methods pub(crate) if they can be
implemented via the pub methods
* Cleanup changes
* word_starts and word_ends functions no longer needed with current
word-level undo tracking algorithm
* `undo` and `redo` don't need to call `update_undo_behavior` because they are
private methods and `run_edit_command` already calls `update_undo_behavior`
* Fix for new clippy warning
* Editor+LineBuffer API updates for nushell merge
* Make `LineBuffer::replace_range` pub rather than pub(crate)
* Make `Editor::set_line_buffer` and `Editor::set_buffer` pub(crate) in
favor of the new `Editor::edit_buffer`.
I believe the `edit_buffer` change is a better API to expose for
`Menu` implementations, as it avoids the need for `clones` while
enforcing proper undo tracking.
Export `crossterm::event::{KeyCode, KeyModifiers}` as our own.
This way users of the library don't have to import crossterm with the
same version explicitly to set their own keybindings.
Closes#456
* Vi mode add support for d0, d^, c0, and c^
Also changes d$ to delete just current line for
multiline inputs
* Make `d0` line aware
* Make `c0` line aware
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
`rstest = 0.12` added support for asynchronous timeouts during testing
thus requiring a larger set of dependencies. Since `rstest = 0.14` this
can be disabled if not used.
Should keep build times for local or CI tests in check.
This new crossterm version includes a breaking change to the indexing of
certain cursor move operations:
https://github.com/crossterm-rs/crossterm/releases/tag/0.24
While reedline itself might not be affected, check the code of the
consuming application that needs to match the crossterm version!
> Switch case of the character under the cursor and move the cursor to
> the right.
vi behavior is to only swap the case of an ASCII character so this is
implementation matches that behavior
* Support vi mode ; and , motions
The f, F, t, and T left-right motions can be repeated with the ; motion,
or reversed with the , motion:
> ; Repeat latest f, t, F or T [count] times. See cpo-;
>
> , Repeat latest f, t, F or T in opposite direction
> [count] times. See also cpo-;
I named these "to-till" motions as the first word of the description for
the f and T motions are "To" and "Till" respectively.
Add storage for the last To or Till motion on the `Vi` struct, and pass
it through to `parse_command()` so `;` or `,` can re-use it.
When a to-till motion is fully parsed the new to-till motion is stored
in the `Vi` struct.
* Correctly implement ,
The last to or till motion should be recorded from f, F, t, or T.
Using , to reverse the to/till motion must not change the motion that
will be replayed.
In other words, if you f to move to the right then pressing , will only
move you left. Pressing , will not swap between the two matching
characters your cursor is on or between.
* Fix clippy
This is an incomplete implementation as it omits the behaviors for
CTRL-V, CTRL-E, and CTRL-Y:
> Replace the character under the cursor with {char}. If {char} is a
> <CR> or <NL>, a line break replaces the character. To replace with a
> real <CR>, use CTRL-V <CR>. CTRL-V <NL> replaces with a <Nul>.
>
> If {char} is CTRL-E or CTRL-Y the character from the line below or
> above is used, just like with |i_CTRL-E| and |i_CTRL-Y|. This also
> works with a count, thus `10r<C-E>` copies 10 characters from the line
> below.
The similarly-named ReplaceChars is used for history substitution and
is more complicated than we need (n_chars will always be 1, string will
always be a single character string), but could be used if the extra
replace_char() function is too much.
* Add vi W motion
This moves forward by WORD which is a sequence of non-blank characters
separated by whitespace.
* Add vi B motion
Support deleting backward for word (db) and WORD (dB)
* Add vi E motion
Makes the history querying structs and enums pub as it seems reasonable
for now. Useful to create nushells `history` command.
Might make sense to change that API to something simpler cleaner later.
Changes the history API to support different storage backends and more rich information to be used as metadata/filtering criterions.
Includes a SQLite backed history with additional fields and ports the simple `FileBackedHistory` format consistent.
Includes a `HistoryCursor` to abstract the internal interactive browsing.
Updates `History` trait to cover the API to load and store to the storage backend.
Commits
* basic sqlite history
* fix test compilation
* final touches for MVP
* better documentation
* fix for empty history
* partial change to non-generic history
* mostly working
* fix tests and ci
* fixes, format
* move history item to new file
* fix some comments, fix test compile errors
todo: fix tests
* ci features matrix
* fix index creation
* fix file-based tests
* move logic for not saving empty entries to engine
* fix update last command on empty, set up application_id and check version
* add specific error variants
* format
* fix compile errors
* fix fmt
* sqlite with bashisms
* hide with features
* cargo fmt
* improve performance of bashisms selectors
* Style: Remove commented out code
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Co-authored-by: Fernando Herrera <fernando.j.herrera@gmail.com>
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
* Fix clippy lints that will become warnings
clippy from the nightly future
* Revent false positive `.to_string()` removal
This [lint](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned) is nasty as `ansi_term` and thus `nu_ansi_term` on their `AnsiGenericString` implement `Display` to apply the styling and `Deref` to just return the underlying `&str`.
As [`ToString` is implemented for any `T: Display + ?Sized` ](https://doc.rust-lang.org/std/string/trait.ToString.html#impl-ToString-6) the to_string implementation relies on the `Display` defined for the type alias `AnsiString` and not on the `impl ToString for str` for the `&str` accessible through `Deref`.
Applying the suggested fix will remove syntax highlighting!!!
* don't panic whan parent directory is not exists
* no need to check parent exists
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
Group the common keybindings into three functions:
- `add_common_control_bindings`
- `add_common_navigation_bindings`
- `add_common_edit_bindings`
Vi normal uses the first two
Vi insert uses all of them
Emacs extends upon those
Goals:
- Provide pointers to further reading for folks not too familiar with the
problem set on the terminal
- Explain the architecture a bit to get people up to speed
The code didn't account for the index
and the indicator in its calculation for
the number of lines in the list_menu.
Now the unicode_width of the indicator and the
number of digits of the index are accountet for.
Amortized growing of the history based on the amount read from the file
is cheap. Allocating for the capacity is expensive and can cause OOM for
large capacities.
Fix for nushell/nushell#5593
* Fix vi-mode word motions
The 'w' motion goes to the beginning of the next word to the right, not
the end. The 'e' motion, which is introduced here, goes to the end, but
lands on the last character, not after it.
* Add test case for `move_word_right_end`
Ensure Unicode safety as well as that the cursor will move to the next
word end when already at a word end
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
- Fix README and lib.rs code examples
- Add missing doctests
- Fix the completion example in README
- Fix the edit mode example
- Try to run more of the doctests
- They should not block with the IO loop or do file IO as this was failing the CI
Adding a space when accepting a completion avoids rerunning the same already accepted completion when working with a space tokenized language like nushell
* Add append_whitespace choice for suggestion
Signed-off-by: gipsyh <gipsyh.icu@gmail.com>
* Update src/completion/base.rs
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
* Update src/menu/columnar_menu.rs
Signed-off-by: gipsyh <gipsyh.icu@gmail.com>
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
- vim's 'S' binding
- copy char while deleting in vi mode
- Fixes the behavior of `x` so the removed char/grapheme can be pasted with `p`
- vim's 's' binding
- Minor clarifications by @sholderbach
- Fix doccomments and clarify an enum variant's name
Rebased the commits from #406
Co-authored-by: zim0369 <zim@onionmail.org>
Clearing the scrollback did not work on most terminal emulators.
By reordering two ANSI control sequences, this seems to work on Linux
with most terminal emulators.
Due to a missing implementation of the exact details this will probably
not clear the scrollback under the old Windows API.
Related to the discussion in #120 and nushell/nushell#5089
* Change the CI to use caching
This tries to replicate the cargo caching techniques developed by @rgwood on the [nushell](https://github.com/nushell/nushell) repo to save time (and energy) on the CI pipeline.
## Further reading:
[Reilly's blog post](https://www.reillywood.com/blog/rust-faster-ci/)
* Simplify to one job per build matrix combination
This should save some setup time.
And as rebuilds and tests of reedline are fast enough we can just be parallel over the feature
configurations.