Commit graph

1795 commits

Author SHA1 Message Date
Michael Davis
c74b97447f
Fix range offsets for multiple shell insertions (#4619)
d6323b7cbc introduced a regression for
shell commands like `|`, `!`, and `<A-!>` which caused the new
selections to be incorrect. This caused a panic when piping (`|`)
would cause the new range to extend past the document end.

The paste version of this bug was fixed in
48a3965ab4.

This change also inherits the direction of the new range from the old
range and adds integration tests to ensure that the behavior isn't
broken in the future.
2022-11-14 09:45:52 +09:00
wes adams
fd585c1ee4
Statusline indicator to show number of selected chars (#4682)
Co-authored-by: wes adams <wadams@grayshift.com>
2022-11-12 11:31:09 -06:00
asvln
1f72d34249 rename description for goto_line_end_newline 2022-11-11 19:14:08 -06:00
asvln
7468fa28fd add extend_prev_word_end command 2022-11-11 19:14:08 -06:00
Bruce Hopkins
bc0a3037ea
feat(commands): increment by range (#4418) 2022-11-11 13:50:25 -05:00
Blaž Hrastnik
758bace221
fix test compilation 2022-11-09 22:17:14 +09:00
Blaž Hrastnik
264a455c18
Move terminal out of compositor 2022-11-09 22:10:49 +09:00
Blaž Hrastnik
00d7b18097
This term specific behavior really doesn't belong to compositor 2022-11-09 21:47:46 +09:00
Blaž Hrastnik
b2e7171fed
Drop terminal interaction in compositor.size() 2022-11-09 21:37:56 +09:00
Blaž Hrastnik
d4f5cab7b5
Re-enable format_selections for a single selection range 2022-11-09 18:17:23 +09:00
Matthias Deiml
dee5b2a983
Add LSP workspace command picker (#3140)
* Add workspace command picker

* Make command typable

* Add optional argument to lsp-workspace-command
2022-11-09 18:17:09 +09:00
Marko Klobučar Ledinšćak
d8e9c85f5e
error! on unknown CompletionItemKind (#4658) 2022-11-08 12:36:01 -06:00
Doug Kelkhoff
7ed9e9cf25
Dynamically resize line number gutter width (#3469)
* dynamically resize line number gutter width

* removing digits lower-bound, permitting spacer

* removing max line num char limit; adding notes; qualified successors; notes

* updating tests to use new line number width when testing views

* linenr width based on document line count

* using min width of 2 so line numbers relative is useful

* lint rolling; removing unnecessary type parameter lifetime

* merge change resolution

* reformat code

* rename row_styler to style; add int_log resource

* adding spacer to gutters default; updating book config entry

* adding view.inner_height(), swap for loop for iterator

* reverting change of current! to view! now that doc is not needed
2022-11-08 21:19:59 +09:00
Blaž Hrastnik
c94feed83d
core: Move state into the history module 2022-11-08 21:03:54 +09:00
Blaž Hrastnik
13126823f8
lsp: Support insertReplace
Fixes #4473
2022-11-08 20:50:49 +09:00
Michael Davis
140df92d79 Fix command-mode completion behavior when input is escaped
If `a\ b.txt` were a local file, `:o a\ <tab>` would fill the prompt
with `:o aa\ b.txt` because the replacement range was calculated using
the shellwords-parsed part. Escaping the part before calculating its
length fixes this edge-case.
2022-11-07 13:38:16 +09:00
Michael Davis
3d283b2ca4 Escape filenames in command completion
This changes the completion items to be rendered with shellword
escaping, so a file `a b.txt` is rendered as `a\ b.txt` which matches
how it should be inputted.
2022-11-07 13:38:16 +09:00
Michael Davis
1536a65289 Fix whitespace handling in command-mode completion
8584b38cfb switched to shellwords for
completion in command-mode. This changes the conditions for choosing
whether to complete the command or use the command's completer.

This change processes the input as shellwords up-front and uses
shellword logic about whitespace to determine whether the command
or argument should be completed.
2022-11-07 13:38:16 +09:00
Michael Davis
48a3965ab4
Fix range offsets in multi-selection paste (#4608)
* Fix range offsets in multi-selection paste

d6323b7cbc introduced a regression with
multi-selection paste where pasting would not adjust the ranges
correctly. To fix it, we need to track the total number of characters
inserted in each changed selection and use that offset to slide each
new range forwards.

* Inherit selection directions on paste

* Add an integration-test for multi-selection pasting
2022-11-06 23:56:45 +09:00
Michael Davis
3814987298
Fix panic on paste from blackhole register (#4497)
The sequence "_y"_p panics because the blackhole register contains an
empty values vec. This causes a panic when pasting since it unwraps
a `slice::last`.
2022-11-05 01:04:16 +09:00
Michael Davis
d6323b7cbc
Select text inserted by shell or paste (#4458)
This follows changes in Kakoune to the same effects:

* p/<space>p: 266d1c37d0
* !/<A-!>: 85b78dda2e

Selecting the new data inserted by shell or pasting is often more
useful than retaining a selection of the pre-paste/insert content.
2022-11-05 01:02:19 +09:00
Blaž Hrastnik
c2c1280f02
Resolve a bunch of upcoming clippy lints 2022-11-04 21:06:28 +09:00
Michael Davis
ba394dca6d
Fix panic from two windows editing the same document (#4570)
* Clamp highlighting range to be within document

This fixes a panic possible when two vsplits of the same document
exist and enough lines are deleted from the document so that one of
the windows focuses past the end of the document.

* Ensure cursor is in view on window change

If two windows are editing the same document, one may delete enough of
the document so that the other window is pointing at a blank page (past
the document end). In this change we ensure that the cursor is within
view whenever we switch to a new window (for example with `<C-w>w`).

* Update helix-term/src/ui/editor.rs

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

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-11-03 15:09:21 +09:00
Jonathan LEI
db3383c76e
Exit select mode on replace commands (#4554) 2022-11-01 20:08:25 -05:00
Yuriy Gabuev
c803ef8753
Fix delete_char_backward for paired characters (#4558)
When backward-deleting a character, if this character and the following
character form a Pair, we want to delete both. However, there is a bug
that deletes both characters also if both characters are closers of some
Pair.

This commit fixes that by adding an additional check that the deleted
character should be an opener in a Pair.

Closes https://github.com/helix-editor/helix/issues/4544.
2022-11-01 23:48:43 +09:00
Armin Ronacher
8584b38cfb
Correctly handle escaping in completion (#4316)
* Correctly handle escaping in completion

* Added escaping tests
2022-11-01 20:48:37 +09:00
dependabot[bot]
e5319ea8c5
build(deps): bump once_cell from 1.15.0 to 1.16.0 (#4548)
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: once_cell
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-31 19:31:08 -05:00
Matthew Toohey
00cf12f571
fix: make scroll aware of tabs and wide characters (#4519) 2022-10-29 16:23:18 -05:00
Matthias Deiml
5e256e4a98
Make shell_impl concurrent (#3180) 2022-10-29 10:24:33 -05:00
Poliorcetics
c58e1729ce
fix: Never create automatic doc popups outside of Insert mode (#4456) 2022-10-28 18:20:55 -05:00
Michael Davis
cefdface3b
Include colons for typable commands in command palette (#4495)
Before:

    Goto next buffer. [buffer-next]

After:

    Goto next buffer. [:buffer-next]
2022-10-28 21:42:40 +09:00
Dario Oddenino
6752c7d347
Trim quotes and braces from paths in goto_file_impl (#4370)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2022-10-27 20:31:28 -05:00
lazytanuki
b4a3dd8f89
feat(lsp): LSP preselected items appear first in completion menu (#4480)
* feat(lsp): LSP preselected items appear first in completion menu

* fix: shorter diff
2022-10-27 23:16:55 +09:00
James O. D. Hunt
ac0fe29867
commands: Make no arg ':theme' show name (#3740)
Most commands that accept an argument show their current value if no
argument is specified. The `:theme` command previously displayed an
error message in the status bar if not provided with an argument:

```
Theme name not provided
```

It now shows the current theme name in the status bar if no argument is
specified.

Signed-off-by: James O. D. Hunt <jamesodhunt@gmail.com>

Signed-off-by: James O. D. Hunt <jamesodhunt@gmail.com>
2022-10-26 11:59:50 +09:00
Gaurav Tyagi
ba9e50e93b
Add :update that will write the changes if the file has been modified. (#4426)
* add command update that will write the changes if file hasn been modified

* add docs

* update the docs
2022-10-26 11:58:49 +09:00
Michał Zabielski
65edf9c198
fix: repeating repeat operator (#4450) 2022-10-25 21:15:46 -05:00
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.
2022-10-25 20:24:44 -05:00
Michael Davis
c47ca33137
Render diagnostics in the file picker preview (#4324)
This is mostly for the sake of the diagnostics pickers: without
rendering the diagnostic styles, it's hard to tell where the entries
in the picker are pointing to.
2022-10-25 21:03:35 +09:00
Michael Davis
d7d0d5ffb7
lsp: Resolve completion items missing documentation on idle (#4406)
Some language servers may not send the `documentation` field if it
is expensive to compute. Clients can request the missing field with
a completionItem/resolve request.

In this change we use the idle-timeout event to ensure that the current
completion item is resolved.
2022-10-22 10:04:50 +09:00
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.
2022-10-21 07:42:33 -05:00
Alexis (Poliorcetics) Bourget
3aea33a415 nit: move an allocation to happen after a continue, making sure it's
not done for nothing
2022-10-21 07:42:33 -05:00
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.
2022-10-21 16:43:22 +09:00
Nimrod
bad49ef2d0
Fix unexpected behavior in delete_word_backward and delete_word_forward (#4392) 2022-10-21 15:08:37 +09:00
Skyler Hawthorne
f486f34ebe
flush writes on force quit (#4397)
When force quitting, we need to block on the pending writes to ensure
that write commands succeed before exiting, and also to avoid a crash
when all the views are gone before the auto format call returns from
the LS.
2022-10-21 13:28:29 +09:00
Charlie Groves
7e29ee6dae
Autosave all when the terminal loses focus (#3178)
* Autosave all when the terminal loses focus

* Correct comment on focus config

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

* Need a block_try_flush_writes in all quit_all paths

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-10-21 10:35:02 +09:00
Pascal Kuthe
9af7c1c9f3 Sort by fixed diagnostics/is_preffered within codeaction categories 2022-10-21 10:03:00 +09:00
Pascal Kuthe
189aa0bfcf never sort menu items when no fuzzy matching is possible 2022-10-21 10:03:00 +09:00
Pascal Kuthe
dc3527f52d use permalink to vscode repo 2022-10-21 10:03:00 +09:00
Pascal Kuthe
8d8b5d6624 use stable sort instead of allocating new vectors 2022-10-21 10:03:00 +09:00
Pascal Kuthe
c70d762a7b sort autocompletins by fuzzy match 2022-10-21 10:03:00 +09:00