Commit Graph

821 Commits (de5b100556ce4d9a2f739bd54904246f97dc6863)

Author SHA1 Message Date
GabrielDertoni 9fae4b8118 fix: terminal freezing on `shell_insert_output`
This bug occurs on `shell_insert_output` and `shell_append_output`
commands.

The previous implementation would create a child process using the Rust
stdlib's `Command` builder. However, when nothing should be piped in
from the editor, the default value for `stdin` would be used. According
to the Rust stdlib documentation that is `Stdio::inherit` which will
make the child process inherit the parent process' stdin. This would
cause the terminal to freeze.

This change will set the child process' stdin to `Stdio::null` whenever
it doesn't pipe it. In the `if` statement where this change was made
there was an extra condition for windows that I am not sure if would
require some special treatment.
2 years ago
Alexis (Poliorcetics) Bourget 34389e1d54 nit: Do less allocations in `ui::menu::Item::label` implementations
This complicates the code a little but it often divides by two the number of allocations done by
the functions. LSP labels especially can easily be called dozens of time in a single menu popup,
when listing references for example.
2 years ago
Skyler Hawthorne 5a848344a9
fix: write-all crash (#4384)
When we do auto formatting, the code that takes the LSP's response and applies
the changes to the document are just getting the currently focused view and
giving that to the function, basically always assuming that the document that
we're applying the change to is in focus, and not in a background view.

This is usually fine for a single view, even if it's a buffer in the
background, because it's still the same view and the selection will get updated
accordingly for when you switch back to it. But it's obviously a problem for
when there are multiple views, because if you don't have the target document in
focus, it will ask the document to update the wrong view, hence the crash.

The problem with this is picking which view to apply any selection change to.
In the absence of any more data points on the views themselves, we simply pick
the first view associated with the document we are saving.
2 years ago
Nimrod bad49ef2d0
Fix unexpected behavior in delete_word_backward and delete_word_forward (#4392) 2 years ago
Matouš Dzivjak 4cff625054
chore(view): remove indent_unit helper fn (#4389) 2 years ago
Matouš Dzivjak eee8362015
fix(commands): no last picker error (#4387) 2 years ago
Blaž Hrastnik 30c93994b5 Use a single save_queue on the editor 2 years ago
Skyler Hawthorne 3f07885b35 document should save even if formatter fails 2 years ago
Skyler Hawthorne b3fc31a211 move language server refresh to document saved event handler 2 years ago
Skyler Hawthorne aaa1450678 fix write-quit with auto format
write-quit will now save all files successfully even when there is auto
formatting
2 years ago
Skyler Hawthorne c9418582d2 fix modified status with auto format 2 years ago
Skyler Hawthorne b8a07f7d15 add conditional noop render back
It makes it much slower without stubbing this out
2 years ago
Skyler Hawthorne d706194597 chore(write): serialize write operations within a Document
The way that document writes are handled are by submitting them to the
async job pool, which are all executed opportunistically out of order. It
was discovered that this can lead to write inconsistencies when there
are multiple writes to the same file in quick succession.

This seeks to fix this problem by removing document writes from the
general pool of jobs and into its own specialized event. Now when a
user submits a write with one of the write commands, a request is simply
queued up in a new mpsc channel that each Document makes to handle its own
writes. This way, if multiple writes are submitted on the same document,
they are executed in order, while still allowing concurrent writes for
different documents.
2 years ago
Jonathan LEI 1a772d1b67
Fix deleting word from end of buffer (#4328) 2 years ago
Philipp Mildenberger d17ffc47f0
Use the same `WalkBuilder` configuration for the global search file picker as the default file picker (#4334)
Skip searching .git in global search, similar to how file picker skips listing files in .git.
2 years ago
Nathaniel Graham e80beaa7b0
Changed Selection Yank Message (#4275)
Co-authored-by: Nathaniel Graham <ngraham@protonmail.com>
2 years ago
Michael Davis e16c632760
Apply transactions to the jumplist for undo/redo (#4227)
Undo/redo/earlier/later call `Document::apply_impl` which applies
transactions to the document. These transactions also need to be
applied to the view as in 0aedef0.
2 years ago
Armin Ronacher 7f75458e6f
Fix some commands not showing names in palette (#4223) 2 years ago
Graic 68909dcef4
Fix append cursor location when selection anchor is at end of document (#4147) 2 years ago
Alexis (Poliorcetics) Bourget b58899bc8e fix: remove unneeded allocations when calling helix_view::Info::new 2 years ago
Michael Davis c388e16e09 Add a helper function for applying transactions
It is easy to forget to call `Document::apply` and/or `View::apply` in
the correct order. This commit introduces a helper function which
closes over both calls.
2 years ago
Michael Davis 0aedef0333 Apply transactions to Views
This change adds View::apply calls for all Document::apply call-sites,
ensuring that changes to a document do not leave invalid entries in
the View's jumplist.
2 years ago
A-Walrus c927d61791
Fix bugs in search wraparound message (#4101) 2 years ago
Michael Davis 6cca7375ec
Automatically track pseudo-pending text (#4077)
This change automatically tracks pending text for for commands which use
on-next-key callbacks. For example, `t` will await the next key event
and "t" will be shown in the bottom right-hand corner to show that we're
in a pending state.

Previously, the text for these on-next-key commands needed to be
hard-coded into the command definition which had some drawbacks:

* It was easy to forget to write and clear the pending text.
* If a command was remapped in a custom config, the pending text would
  still show the old key.

With this change, pending text is automatically tracked based on the
key events that lead to the command being executed. This works even
when the command is remapped in config and when the on-next-key
callback is nested under some key sequence (for example `mi`).
2 years ago
Michael Davis dbec057363
Rename I/A "Insert at start/end of line" (#3753)
* keymap: Rename A "Insert at end of line"

The language for the `A` binding is potentially confusing because
`A` behaves like `i` done at the end of the line rather than `a`.
This change renames the command to match Kakoune's language[^1].

[^1]: 021da117cf/src/normal.cc (L2229)

* keymap: Rename I `insert_at_line_start`
2 years ago
Ivan Tham 66bbba9024
Select inserted space after join (#3549)
* Select inserted space after join

* Split join_selections with space selection to A-J

Kakoune does that too and some users may still want to retain their selections.

* Update join_selections docs
2 years ago
nuid32 576c34f84e
Add command names to command palette (#4071) 2 years ago
greg-enbala 63ff9309ce
goto_window_* extends selection (#3985)
* goto_window_* extends selection

* Don't push to the jumplist
2 years ago
Michael Davis c253139790 Extend textobject selections in select mode 2 years ago
Michael Davis 032d76ccf2 Use Range::with_direction consistently 2 years ago
Michael Davis 274f2ea459 Use requested direction for new textobject selection range
This changes the behavior of operations like `]f`/`[f` to set the
direction of the new range to the direction of the action.

The original behavior was to always use the head of the next function.
This is inconsistent with the behavior of goto_next_paragraph and makes
it impossible to create extend variants of the textobject motions.

This causes a behavior change when there are nested functions. The
behavior in the parent commit is that repeated uses of `]f` will
select every function in the file even if nested. With this commit,
functions are skipped.

It's notable that it's possible to emulate the original behavior by
using the `ensure_selections_forward` (A-:) command between invocations
of `]f`.
2 years ago
A-Walrus f3958aa1fd
Cycled to end/beginning + no more matches msgs (#3176)
* Show status msg when next/prev cycles around

* Add msg when there is no wraparound

* Cleanup code

* Change msg to "Wrapped around document"
2 years ago
Matt Freitas-Stavola 9d1793c45b
Add pseudo_pending for t/T/f/F (#4062) 2 years ago
zensayyy c9584251f3
Ensure cursor in view after format (#4047)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2 years ago
Riccardo Binetti 888f4fef6f
Split helix_core::find_root and helix_loader::find_local_config_dirs (#3929)
* Split helix_core::find_root and helix_loader::find_local_config_dirs

The documentation of find_root described the following priority for
detecting a project root:
- Top-most folder containing a root marker in current git repository
- Git repository root if no marker detected
- Top-most folder containing a root marker if not git repository detected
- Current working directory as fallback

The commit contained in https://github.com/helix-editor/helix/pull/1249
extracted and changed the implementation of find_root in find_root_impl,
actually reversing its result order (since that is the order that made
sense for the local configuration merge, from innermost to outermost
ancestors).

Since the two uses of find_root_impl have different requirements (and
it's not a matter of reversing the order of results since, e.g., the top
repository dir should be used by find_root only if there's not marker in
other dirs), this PR splits the two implementations in two different
specialized functions.

In doing so, find_root_impl is removed and the implementation is moved
back in find_root, moving it closer to the documented behaviour thus
making it easier to verify it's actually correct

* helix-core: remove Option from find_root return type

It always returns some result, so Option is not needed
2 years ago
A-Walrus eb6fd283dc
Deduplicate regexes in search_selection command (#3941) 2 years ago
Blaž Hrastnik 1acdfaa073
fix: View needs to retain the original scroll offset on split 2 years ago
Michael Davis 9c3c6a1c22
Fix off-by-one in extend_line_above (#3689)
`extend_line_above` (and `extend_line` when facing backwards) skip
a line when the current range does not fully cover a line.

Before this change:

    foo
    b#[|a]#r
    baz

With `extend_line_above` or `extend_line` selected the line above.

    #[|foo
    bar]#
    baz

Which is inconsistent with `extend_line_below`. This commit changes
the behavior to select the current line when it is not already
selected.

    foo
    #[|bar]#
    baz

Then further calls of `extend_line_above` extend the selection up
line-wise.
2 years ago
Blaž Hrastnik 5c2b77b41f
Make mode editor-wide rather than per-document 2 years ago
Saber Haj Rabiee 1cbf552554
fix: prevents storing last prompt if is top of stack (#3609) 2 years ago
Michael Davis 83f177d270
Refactor goto_ts_object_impl as a motion (#3264)
This refactor changes the overall structure of the goto_ts_object_impl
command without removing any functionality from its behavior. The
refactored motion:

* acts on all selections instead of reducing to one selection
* may be repeated with the `repeat_last_motion` (A-.) command
* informs the user when the syntax-tree is not accessible in the current buffer
2 years ago
Michael Davis 701cea54d2
jumplist: Add documents to view history (#3593)
This change adds documents to the view's document history Vec.
(This is used by `ga` for example to access the last buffer.)

Previously, a sequence like so would have confusing behavior:

1. Open file A: any document with an active language server
2. Find some definition that lives in another file - file B - with `gd`
3. Jump back in the jumplist with `C-o` to file A
4. Use `ga` intending to switch back to file B

The behavior prior to this change was that `ga` would switch to file
A: you could not use `ga` to switch to file B.
2 years ago
PiergiorgioZagaria d2cec25395
Fix process spawning error handling (#3349)
* Fix process spawning error handling

* Log stderr in any case
2 years ago
Bob 411c5e4871
let extend-line respect range direction (#3046)
* let extend-line respect range direction

* fix extend above logic

* keep `x` existing binding

* Update book/src/keymap.md

Co-authored-by: Ivan Tham <pickfire@riseup.net>

Co-authored-by: Ivan Tham <pickfire@riseup.net>
2 years ago
Charlie Groves f38ede8631
Add bracketed paste (#3233) 2 years ago
Blaž Hrastnik 7b8e4ac95a
Editor: remove duplication for view focus/swap commands 2 years ago
Saber Haj Rabiee 1577a9d0ab
style: fixes `unused_parens` warnings on nightly builds (#3471) 2 years ago
Daniel S Poulin 7711db3a3a
Adjust `m` textobject description and minor code clarification (#3343)
* Update description of `m` textobject to its actual functionality

Sometime recently the functionality of `m` was changed to match the
nearest pair to the cursor, rather than the former functionality of
matching the pair only if the cursor was on one of the brace characters
directly.

* Rename surround methods to reflect that they work on pairs

The current naming suggests that they may work generally on any
textobject, whereas their implementation really focuses on pairs.

* Change description of m textobject to match actual functionality

The current implementation of `m` no longer merely looks at the pair
character the cursor is on, but actually will search for the pair
(defined in helix-core/src/surround.rs) that encloses the cursor, and
not the entire selection.

* Accept suggested wording change

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

* Prefix pair surround for consistency

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2 years ago
Kyle L. Davis 21f2affa16
Fix conditional setting of stdin handle on Windows (#3379)
* Revert 3121353c6a

* Switch to conditional compilation

* Run formatter

* Switch from conditional compilation to compile-time bool
2 years ago
Gokul Soumya 634b6d455f
Add custom event type replacing crossterm's Event (#3169)
Ported over from 61365dfbf3 in the `gui` branch. This will allow
adding our own events, most notably an idle timer event (useful
for adding debounced input in [dynamic pickers][1] used by interactive
global search and workspace symbols).

[1]: https://github.com/helix-editor/helix/pull/3110

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago