Commit Graph

2193 Commits (main)

Author SHA1 Message Date
Skyler Hawthorne 5b07ce76fc make TestCase::From more generic 1 year ago
Skyler Hawthorne 8c5ec95ac0 factor write command tests to own module 1 year ago
exp80 770496511c
Fix highlighting in picker with multiple columns (#6333) 1 year ago
Pascal Kuthe b6a4927f00 discard outdated workspace edits recived from the LS 1 year ago
Pascal Kuthe 3c9d5d0215 discard outdated diagnostics recived by the LS 1 year ago
Thomas Schollenberger 2a27d1b505
Prevent whitespace from rendering inside inlay hints (#6312)
* fix spaces and nbsps showing in inlay hints

* remove origin

* virtual tab + fix unneeded clone

* update virtual tab determining location

* fix clippy lint
1 year ago
Blaž Hrastnik 75ebc1fcbc
fix compilation 1 year ago
Kyle Smith 27aa919f1c
Only complete appropriate arguments for typed commands. (#5966) 1 year ago
Jonatan Pettersson d479adfdc6
Add undercurl config option #6196 (#6253)
If set to 'true' this option will force terminal undercurl support.
1 year ago
dependabot[bot] b558ce7148
build(deps): bump indoc from 2.0.0 to 2.0.1 (#6302)
Bumps [indoc](https://github.com/dtolnay/indoc) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/dtolnay/indoc/releases)
- [Commits](https://github.com/dtolnay/indoc/compare/2.0.0...2.0.1)

---
updated-dependencies:
- dependency-name: indoc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 year ago
dependabot[bot] 4d4bb07419
build(deps): bump libc from 0.2.139 to 0.2.140 (#6304)
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.139 to 0.2.140.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.139...0.2.140)

---
updated-dependencies:
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 year ago
Francesc Elies d15f9721a5
LSP: Separate diagnostic picker message and code (#6095) 1 year ago
misiasty3 db8e9f5bb2
Check language server symbol renaming support before prompting (#6257)
Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
1 year ago
Cole Helbling 34934733b3
helix-term: send the STOP signal to all processes in the process group (#3546)
* helix-term: send the STOP signal to all processes in the process group

From kill(3p):

    If pid is 0, sig shall be sent to all processes (excluding an unspecified set
    of  system processes) whose process group ID is equal to the process group ID
    of the sender, and for which the process has permission to send a signal.

This fixes the issue of running `git commit`, attempting to suspend
helix with ^Z, and then not regaining control over the terminal and
having to press ^Z again.

* helix-term: use libc directly to send STOP signal

* helix-term: document safety of libc::kill

* helix-term: properly handle libc::kill's failure

I misread the manpage for POSIX `kill` -- it returns `-1` in
the failure case, and sets `errno`, which is retrieved via
`std::io::Error::last_os_error()`, has its string representation printed
out, and then exits with the matching status code (or 1 if, for whatever
reason, there is no matching status code).

* helix-term: expand upon why we need to SIGSTOP the entire process group

Also add a link back to one of the upstream issues.
1 year ago
Michael Davis 4f066b1cc6
LSP: No-op client/registerCapability requests (#6258) 1 year ago
Pascal Kuthe 171d28d2bd
indent snippets to line indent instead of completion start (#6263) 1 year ago
Poliorcetics bdcd4d9411
Feat: LSP Type Hints (#5934)
* misc: missing inline, outdated link

* doc: Add new theme keys and config option to book

* fix: don't panic in Tree::try_get(view_id)

Necessary for later, where we could be receiving an LSP response
for a closed window, in which case we don't want to crash while
checking for its existence

* fix: reset idle timer on all mouse events

* refacto: Introduce Overlay::new and InlineAnnotation::new

* refacto: extract make_job_callback from Context::callback

* feat: add LSP display_inlay_hint option to config

* feat: communicate inlay hints support capabilities of helix to LSP server

* feat: Add function to request range of inlay hint from LSP

* feat: Save inlay hints in document, per view

* feat: Update inlay hints on document changes

* feat: Compute inlay hints on idle timeout

* nit: Add todo's about inlay hints for later

* fix: compute text annotations for current view in view.rs, not document.rs

* doc: Improve Document::text_annotations() description

* nit: getters don't use 'get_' in front

* fix: Drop inlay hints annotations on config refresh if necessary

* fix: padding theming for LSP inlay hints

* fix: tracking of outdated inlay hints should not be dependant on document revision (because of undos and such)

* fix: follow LSP spec and don't highlight padding as virtual text

* config: add some LSP inlay hint configs
1 year ago
Dimitar Gyurov 1661e4b5e1
Add a version-control statusline element (#5682) 1 year ago
Pascal Kuthe d63e570e0a treat replace/insertmode consistently, default to insert 1 year ago
Pascal Kuthe b1f7528090 fix snippet bugs and multicursor completion edgecases
Multicursor completions may overlap and therefore overlapping
completions must be dropped to avoid crashes. Furthermore, multicursor
edits might simply be out of range if the word before/after the cursor
is shorter. This currently leads to crashes, instead these selections
are now also removed for completions.

This commit also significantly refactors snippet transaction generation
so that tabstops behave correctly with the above rules. Furthermore,
snippet tabstops need to be carefully mapped to ensure their position
is correct and consistent with our selection semantics. Finally,
we now keep a partially updated Rope while creating snippet
transactions so that we can fill information into snippets that
depends on the position in the document.
1 year ago
Taylor C. Richberger 9b4326b18b allow LSP insert text to replace non-matching prefixes (#5469)
Most LSPs will complete case-insensitive matches, particularly from
lowercase to uppercase.  In some cases, notably Pyright, this is given
as a simple insert text instead of TextEdit.  When this happens, the
prefix text was left unedited.
1 year ago
paul-scott ce1fb9e64c
Generalised to multiple runtime directories with priorities (#5411)
* Generalised to multiple runtime directories with priorities

This is an implementation for #3346.

Previously, one of the following runtime directories were used:

1. `$HELIX_RUNTIME`
2. sibling directory to `$CARGO_MANIFEST_DIR`
3. subdirectory of user config directory
4. subdirectory of path to helix executable

The first directory provided / found to exist in this order was used as a
root for all runtime file searches (grammars, themes, queries).

This change lowers the priority of `$HELIX_RUNTIME` so that the user
config runtime has higher priority. More significantly, all of these
directories are now searched for runtime files, enabling a user to override
default or system-level runtime files. If the same file name appears
in multiple runtime directories, the following priority is now used:

1. sibling directory to `$CARGO_MANIFEST_DIR`
2. subdirectory of user config directory
3. `$HELIX_RUNTIME`
4. subdirectory of path to helix executable

One exception to this rule is that a user can have a `themes`
directory directly in the user config directory that has higher piority
to `themes` directories in runtime directories. That behaviour has been
preserved.

As part of implementing this feature `theme::Loader` was simplified
and the cycle detection logic of the theme inheritance was improved to
cover more cases and to be more explicit.

* Removed AsRef usage to avoid binary growth

* Health displaying ;-separated runtime dirs

* Changed HELIX_RUNTIME build from src instructions

* Updated doc for more detail on runtime directories

* Improved health symlink printing and theme cycle errors

The health display of runtime symlinks now prints both ends of the
link.

Separate errors are given when theme file is not found and when the
only theme file found would form an inheritence cycle.

* Satisfied clippy on passing Path

* Clarified highest priority runtime directory purpose

* Further clarified multiple runtime details in book

Also gave markdown headings to subsections.

Fixed a error with table indentation not building
table that also appears present on master.

---------

Co-authored-by: Paul Scott <paul.scott@anu.edu.au>
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
1 year ago
gibbz00 2cf4ce2356
Fix `shrink_selection` with multiple cursors. (#6093)
* Fix #6092

Cause were some incorrect assumptions that missed an edge case in the
`Selection.contains()` calculation. Tests were added accordingly.

* Fix Selection.contains() edge-case handling.

Removing the len check short-circuit was the only thing needed as
pointed out by @dead10ck.
1 year ago
Pascal Kuthe aabc8af95d correctly store snapshots when repeating insert-mode actions
Repeating completions currently crates a savepoint when a completion
popup was triggered (so after the request completed). Just like for
normal completions the savepoint must be created at the request.

The occurrence of the completion request was previously not saved in
`last_insert`. To that end a new `InsertEvent::RequestCompletion`
variant has been added. When replayed this event creates a snapshot
that is "actived" by the `TriggerCompletion` event and subsequently
used during any `InsertEvent::CompletiuonApply` events.
1 year ago
Pascal Kuthe 8cb7cdfd7a discard stale completion requests
Completion requests are computed asynchronously to avoid common micro
freezes while editing. This means that once a completion request
completes, the state of the editor might have changed. Currently,
there is a check to ensure we are still in insert mode. However,
we also need to ensure that the view and document hasn't changed
to avoid accidentally using a savepoint with the wrong view/document.

Furthermore, the editor might request a new completion while the
previous completion request hasn't complemented yet. This can
lead to weird flickering or an outdated completion request replacing
a newer completion that has already completed (the LSP server
is not required to process completion requests in order). This change
also needed to ensure determinism/linear ordering so that completion
popup always correspond to the last completion request.
1 year ago
Pascal Kuthe e8898fd9a8 store multiple snapshots on the document at once
Fixing autocomplete required moving the document savepoint before the
asynchronous completion request. However, this in turn causes new bugs:

If the completion popup is open, the savepoint is restored when the
popup closes (or another entry is selected). However, at that point
a new completion request might already have been created which
would have replaced the new savepoint (therefore leading to incorrectly
applied complies).

This commit fixes that bug by allowing in arbitrary number of
savepoints to be tracked on the document. The savepoints are reference
counted and therefore remain valid as long as any reference to them
remains. Weak reference are stored on the document and any reference
that can not be upgraded anymore (hence no strong reference remain)
are automatically discarded.
1 year ago
Pascal Kuthe 2588fa3710 save selection before completion savepoint
Currently, the selection is not saved/restored when completion
checkpoints are applied. This is usually fine because undoing changes
usually restores maps selections back in insert mode. But this is not
always the case and especially problematic in the presence of
multi-cursor completions (since completions are applied relative to
the selection/cursor) and snippets (which can change the selection)
1 year ago
Pascal Kuthe 4300a3ad05 create savepoint before requesting completion 1 year ago
Kyle Smith 44ff8a1df1
LSP: Support textDocument/prepareRename (#6103)
* LSP: Support textDocument/prepareRename

'textDocument/prepareRename' can be used by the client to ask the
server the range of the symbol under the cursor which would be changed
by a subsequent call to 'textDocument/rename' with that position.

We can use this information to fill the prompt with an accurate prefill
which can improve the UX for renaming symbols when the symbol doesn't
align with the "word" textobject. (We currently use the "word"
textobject as a default value for the prompt.)

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

* clippy fixes

* rustfmt

* Update helix-term/src/commands/lsp.rs

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

* Update helix-term/src/commands/lsp.rs

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

* fix clippy from suggestions

* Update helix-term/src/commands/lsp.rs

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

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Clément Delafargue 8dd1ab4899
Softwrapping improvements (#5893)
* use max_line_width + 1 during softwrap to account for newline char

Helix softwrap implementation always wraps lines so that the newline
character doesn't get cut off so he line wraps one chars earlier then
in other editors. This is necessary, because newline chars are always
selecatble in helix and must never be hidden.

However That means that `max_line_width` currently wraps one char
earlier than expected. The typical definition of line width does not
include the newline character and other helix commands like `:reflow`
also don't count the newline character here.

This commit makes softwrap use `max_line_width + 1` instead of
`max_line_width` to correct the impedance missmatch.

* fix typos

Co-authored-by: Jonathan Lebon <jonathan@jlebon.com>

* Add text-width to config.toml

* text-width: update setting documentation

* rename leftover config item

* remove leftover max-line-length occurrences

* Make `text-width` optional in editor config

When it was only used for `:reflow` it made sense to have a default
value set to `80`, but now that soft-wrapping uses this setting, keeping
a default set to `80` would make soft-wrapping behave more aggressively.

* Allow softwrapping to ignore `text-width`

Softwrapping wraps by default to the viewport width or a configured
`text-width` (whichever's smaller). In some cases we only want to set
`text-width` to use for hard-wrapping and let longer lines flow if they
have enough space. This setting allows that.

* Revert "Make `text-width` optional in editor config"

This reverts commit b247d526d69adf41434b6fd9c4983369c785aa22.

* soft-wrap: allow per-language overrides

* Update book/src/configuration.md

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

* Update book/src/languages.md

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

* Update book/src/configuration.md

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

---------

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
Co-authored-by: Jonathan Lebon <jonathan@jlebon.com>
Co-authored-by: Alex Boehm <alexb@ozrunways.com>
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
1 year ago
Kyle Smith f4bdbe4674
Do not add intermediate lines to jumplist with :<linenum> command. (#5751)
* Do not add intermediate lines to jumplist with :<linenum> command.

* Revert jumplist index changes.

* Reduce calculations during update cycle.

* Use jumplist for undo, set jumplist before preview.

* remove some debug logging

* Revert "remove some debug logging"

This reverts commit 5772c4327e7121c53ea0726a4d7333ae1c413ffb.

* Revert "Use jumplist for undo, set jumplist before preview."

This reverts commit f73a1b29824feaf16477b9df547fb28d9db81923.

* Add last_selection, update implementation.

* @pascalkuthe initial feedback

* Ensure ":goto 123" keybinding works as expected.

* fix clippies, prefer expect() for expect last_selection state
1 year ago
Michael Davis 0c6d25acae
DynamicPicker: Recalculate column widths for new options (#6004)
This fixes blank row text in a DynamicPicker which is initially given
no options. This can happen for language servers which respond to
the workspace symbol request for an empty query with an empty list
of symbols, and that behavior is somewhat common since returning all
symbols as the spec suggests is very expensive.

For empty options, `Picker::new` calculated the widths of each column
as 0. We can recalculate the column widths when the new options are
set to fix this. This refactor is also a good opportunity to formalize
setting new options on a picker: besides setting the new options and
calculating column widths we also want to reset the cursor and rescore
the options.
1 year ago
Michael Davis 6dc017b9e2
Jump to symbol ranges in LSP goto commands (#5986)
This follows prior changes like 42ad1a9e: we select the range given
by the language server rather than the starting point.
1 year ago
Michael Davis 170593161c
LSP: Send replies for malformed and unhandled RPC requests (#6058)
Previously we did not respond to malformed or unhandled LSP requests.
The JSONRPC spec says that all non-notification requests must have
responses:

> When a rpc call is made, the Server MUST reply with a Response,
> except for in the case of Notifications

(Note that Helix is the "Server" in this case. Also from the spec:
"The Server is defined as the origin of Response objects and the
handler of Request objects.")

So this change sends error replies for requests which can't be parsed
or handled. Request IDs are also now added to the log messages for
unhandled requests.
1 year ago
Michael Davis 3d85024717 Move terminal claim/restore code to helix-tui
This moves the `Application::claim_term` and
`helix-term::application::restore_term` functions into the helix-tui
crate. How the terminal should be claimed and restored is a TUI concern
and is implemented differently through different TUI backends.

This cleans out a lot of crossterm and TUI code in Application and
makes it easier to modify claim/restore based on information we query
from the terminal host. The child commit will take advantage of this
to cache the check for whether the host terminal supports the keyboard
enhancement protocol. Without this change, caching that information
takes much more code which is not easily reusable for anything else.

The code to restore the terminal is somewhat duplicated by this patch:
we want to restore the terminal in cases of panics. Panic handler hooks
must live for `'static` and the Application's terminal does not.
1 year ago
Pascal Kuthe 48b6aa9a69
Add command for resetting diff hunks (#5736) 1 year ago
Andrii Grynenko 8c2e447b16 Handle snippets for LSPs not providing offsets for completion 1 year ago
Andrii Grynenko 1866b43cd3 Render every LSP snippets for every cursor
This refactors the snippet logic to be largely unaware of the rest of
the document. The completion application logic is moved into
generate_transaction_from_snippet which is extended to support
dynamically computing replacement text.
1 year ago
Pascal Kuthe ba24cfe912 Delete snippet placeholders when accepting completion
When accepting a snippet completion we automatically delete the
placeholders for now as doing so manual is quite cumbersome. In the
future we should keep these as a mark + virtual text that is
automatically removed once the cursor moves there.
1 year ago
Michael Davis b9b1ec2208 Apply snippets as transactions 1 year ago
Davide Galassi f976c004e2
Allow LSP server to be stopped (#5964) 1 year ago
dependabot[bot] 84be5cd52c
build(deps): bump grep-regex from 0.1.10 to 0.1.11 (#6215)
Bumps [grep-regex](https://github.com/BurntSushi/ripgrep) from 0.1.10 to 0.1.11.
- [Release notes](https://github.com/BurntSushi/ripgrep/releases)
- [Changelog](https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/ripgrep/compare/grep-regex-0.1.10...0.1.11)

---
updated-dependencies:
- dependency-name: grep-regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 year ago
dependabot[bot] c00baf7da6
build(deps): bump grep-searcher from 0.1.10 to 0.1.11 (#6213)
Bumps [grep-searcher](https://github.com/BurntSushi/ripgrep) from 0.1.10 to 0.1.11.
- [Release notes](https://github.com/BurntSushi/ripgrep/releases)
- [Changelog](https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/ripgrep/compare/grep-searcher-0.1.10...0.1.11)

---
updated-dependencies:
- dependency-name: grep-searcher
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 year ago
Filip Dutescu 376c19e06b
feat(dap): implement Restart request (#5651)
Add a restart debug session command, which would issue a
[Restart Request][1], if the debugger supports it and a session is
running. It uses the same arguments and requests used to start the
initial session, when recreating it.

It builds upon #5532, making use of the changes to the termination
workflow of a session.

[1]: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Restart

Closes: #5594

Signed-off-by: Filip Dutescu <filip.dutescu@gmail.com>
1 year ago
Santiago Vrancovich 39d5fb0e59
Remove centering view from Unimpaired commands (#6193)
Remove `align_view` calls from `goto_*_diag` as per issue #6177
1 year ago
nuid32 def26966d2
Fix lacking space panic (#6109)
* Fix lack of space for popup crash

* Fix saturating -> wrapping

* Fix wrapping -> saturating (I am an idiot)

* Remove useless "mut" in helix-tui/src/buffer.rs

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

* Remove redundant bound-check

* Return bound-check back

* Add bound-check for set_style

* Remove set_style bound-check

* Revert bound-check

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Pascal Kuthe ccdb144665 update MSRV to 1.65 1 year ago
Alexander Brevig a2e54167d8
fix: Handle signals before crossterm events (#6170)
This is a workaround for a freeze when suspending Helix with C-z on
non-Windows systems. The check for the keyboard enhancement protocol
locks up crossterm's internal event reading/polling system by trying to
set up multiple concurrent readers. `input_stream.next()` sets up one
reader looking for regular crossterm events while the
`supports_keyboard_enhancement` query sets up another looking for
internal events. The latter hangs for two seconds or until the former
yields an event. By handling signals first we don't lock up the mutex
by trying to read keyboard events.
1 year ago
nuid32 ddc5bf4e60
Fix 'attempt to divide by zero' panic (#6155) 1 year ago
NomisIV c082ef2863
Fix indentation lines (#6134) (#6136) 1 year ago
Michael Davis 27211abf06
Ignore key-release keyboard events (#6139)
Since crossterm 0.26.x, we receive press/release keyboard events on
Windows always. We can ignore the release events though to emulate
the behavior of keyboard input on Windows on crossterm 0.25.x.
1 year ago
lesleyrs 8dab8a0a03 Add shift-backspace keybind alias for backspace (#4937)
When the Kitty Keyboard Protocol is enabled, S-backspace is
distinguished from backspace with no modifiers. This is awkward when
typing because it's very easy to accidentally hold shift and press
backspace temporarily when typing capital letters.

Kakoune (which is also a Kitty Keyboard Protocol application) treats
S-backspace as backspace too:
3150e9b3cd/src/input_handler.cc (L1275)
1 year ago
Michael Davis a066815833 Enable the enhanced keyboard protocol if supported 1 year ago
Michael Davis 79bf5e3094 Update crossterm to 0.26.1
Crossterm 0.26.x includes a breaking change for the command to set the
cursor shape. This commit includes a change which uses the new type.
1 year ago
dependabot[bot] f02fdd2f73
build(deps): bump tempfile from 3.3.0 to 3.4.0 (#6128)
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/Stebalien/tempfile/releases)
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/NEWS)
- [Commits](https://github.com/Stebalien/tempfile/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 year ago
Yusuf Bera Ertan e5af0f1d49
build(nix): update flake to use flake-parts and nci flake-parts module 1 year ago
Filip Dutescu 44729fbaf9
fix(dap): validate key and index exist when requesting vars (#5628)
Check if the stack frames contain the thread id and the frame before
trying to get the frame id. If case any of the two fails to be
found, provide the user with messages to inform them of the issue and
gracefully return.

Closes: #5625

Signed-off-by: Filip Dutescu <filip.dutescu@gmail.com>
1 year ago
Filip Dutescu e3765ac6d2
feat(dap): send Disconnect if Terminated event received (#5532)
Send a `Disconnect` DAP request if the `Terminated` event is received.
According to the specification, if the debugging session was started by
as `launch`, the debuggee should be terminated alongside the session. If
instead the session was started as `attach`, it should not be disposed of.

This default behaviour can be overriden if the `supportTerminateDebuggee`
capability is supported by the adapter, through the `Disconnect` request
`terminateDebuggee` argument, as described in
[the specification][discon-spec].

This also implies saving the starting command for a debug sessions, in
order to decide which behaviour should be used, as well as validating the
capabilities of the adapter, in order to decide what the disconnect should
do.

An additional change made is handling of the `Exited` event, showing a
message if the exit code is different than `0`, for the user to be aware
off the termination failure.

[discon-spec]: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect

Closes: #4674

Signed-off-by: Filip Dutescu <filip.dutescu@gmail.com>
1 year ago
Guillaume 78a1e2db60
feat: show current language when no argument is provided (#5895) 1 year ago
Triton171 a1a6d5f334
Replace incorrect usages of tab_width with indent_width. (#5918) 1 year ago
Erasin b7fb52d0e4
fix: decode lsp url for workspace_diagnostics_picker (#6016) 1 year ago
Jonathan LEI 9368ac76b3
Ignore invalid file URIs from LSP (#6000) 1 year ago
Pascal Kuthe c332b16855
ignore case while filtering completions (#6008) 1 year ago
Michael Davis d8526a752c
Use Popup::ignore_escape_key helper for completion (#6006)
The completion component has a separate branch for handling the
Escape key but it can use the `ignore_escape_key` helper added for
signature-help instead.

This should not cause a behavior change - it's just cleaning up the
completion component.
1 year ago
Pascal Kuthe 715c4b24d9
Fix crash in goto_window_center at EOF (#5987) 1 year ago
Matouš Dzivjak 2bebc5042e
feat(ui): deprecated completions (#5932)
* feat(ui): deprecated completions

Mark deprecated completions using strike-through
(CROSSED_OUT modifier). The deprection information
is taken either from the `deprecated` field of the
completion item or from the completion tags.

The field seems to be the older way of passing
the deprecated information and it was already
marked as deprecated for Symbol. In completion
item the field is still valid but it seems that
the LSP is moving in the general direction of using
tags for this kind of information and as such
relying on tags as well seems reasonable and
future-proof.
1 year ago
A-Walrus 8b09b00942
Add :toggle-option command (#4085)
This command toggles the value of boolean options
1 year ago
Gokul Soumya 425315d752 Fix completion doc popup area calculation logic
Earlier the doc popup would draw over the compeltion popup
itself and sometimes over the cursor too.
1 year ago
Gokul Soumya 1562b5ce67 Create popup rect instead of using raw values 1 year ago
Gokul Soumya 0f844ef191 Refactor our Markdown construction in completion doc 1 year ago
Gokul Soumya 937825e8fc Rename completion doc popup area variables 1 year ago
Gokul Soumya 8e9c329952 Use early return in rendering completion doc 1 year ago
Pascal Kuthe 93c7afc4ed
Negotiate LSP Position Encoding (#5894)
So far LSP always required that `PositionEncoding.characters` is an
UTF-16 offset. Now that LSP 3.17 is available in `lsp-types` request
the server to send char offsets (UTF-32) or byte offsets (UTF-8)
instead. For compatability with old servers, UTF-16 remains as the
fallback as required by the standard.
1 year ago
Daniel S Poulin 6929a12f29
Make `m` textobject look for pairs enclosing selections (#3344)
* Make `m` textobject look for pairs enclosing selections

Right now, this textobject only looks for pairs that surround the
cursor. This ensures that the pair found encloses each selection, which
is likely to be intuitively what is expected of this textobject.

* Simplification of match code

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

* Adjust logic for ensuring surround range encloses selection

Prior, it was missing the case where the start of the selection came
before the opening brace. We also had an off-by-one error where if the
end of the selection was on the closing brace it would not work.

* Refactor to search for the open pair specifically to avoid edge cases

* Adjust wording of autoinfo to reflect new functionality

* Implement tests for surround functionality in new integration style

* Fix handling of skip values

* Fix out of bounds error

* Add `ma` version of tests

* Fix formatting of tests

* Reduce indentation levels for readability, and update comments

* Preserve each selection's direction with enclosing pair surround

* Add test case for multiple cursors resulting in overlap

* Mark known failures as TODO

* Make tests multi-threaded or they fail

* Cargo fmt

* Fix typos in integration test comments

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
lesleyrs af1157f37c
Add exit code to command failed msg (#5898) 1 year ago
Colton Clemmer ea3293b4da
Split modification indicator from file statusline elements (#4731) 1 year ago
Pascal Kuthe 8a3ec443f1
Fix new clippy lints (#5892) 1 year ago
Mike Trinkala 9d73a0d112
Fix the infinite loop when copying the cursor to the top of the file (#5888)
Example:
```
test
testitem
```

Select line 2 with x, then type Alt-C; Helix will go into an infinite
loop. The saturating_sub keeps the head_row and anchor_row pinned at 0,
and a selection is never made since the first line is too short.
1 year ago
Blaž Hrastnik 8a602995fa
Address new clippy lints 1 year ago
Pascal Kuthe e474779c87
bump msrv to 1.63 (#5570)
* bump msrv to 1.63

* resolve new complex type clippy lints
1 year ago
Clément Delafargue f386ff795d
Check for external file modifications when writing (#5805)
`:write` and other file-saving commands now check the file modification
time before writing to protect against overwriting external changes.

Co-authored-by: Gustavo Noronha Silva <gustavo@noronha.dev.br>
Co-authored-by: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com>
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
1 year ago
Michael Davis 23ed8c12f1
Select change range for goto_first/last_change commands (#5206)
This matches the behavior from 42ad1a9e04
but for the first and last change. The selection rules are the same
as for goto_next/prev_change: additions and modifications select the
added and modified range while deletions are represented with a point.
1 year ago
Skyler Hawthorne b2e83f81e1
enable rendering in integration tests (#5819)
This will allow testing more of the code base, as well as enable UI-
specific testing.

Debug mode builds are prohibitively slow for the tests, mostly
because of the concurrency write tests. So there is now a profile for
integration tests that sets the optimization level to 2 for a few helix
crates, and lowers the number of rounds of concurrent writes to 1000.
1 year ago
William Etheredge f7bd7b5eaf
Add :character-info command (#4000) 1 year ago
Pascal Kuthe 350535208f
always commit to history when pasting (#5790) 1 year ago
Skyler Hawthorne a5233cf5ad disable lsp in integration tests 1 year ago
Filipe Azevedo 8ba0a46274
add picker: current view dir (#4666) 1 year ago
Dylan Bulfin 61e1e6160a
Removing C-j and C-k from completion menu navigation (#5070) 1 year ago
Pascal Kuthe f0c2e898b4
add substring matching options to picker (#5114) 1 year ago
Gokul Soumya e31943c4c4
Tabulate buffer picker contents (#5777) 1 year ago
Pascal Kuthe 2949bb018c
fix position translation at EOF with softwrap (#5786) 1 year ago
Pascal Kuthe 6ed2348078
Hide duplicate symlinks from the picker (#5658)
* hide duplicate symlinks from the picker

* Apply suggestions from code review

Co-authored-by: g-re-g <123515925+g-re-g@users.noreply.github.com>

* minor stylistic fix

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

---------

Co-authored-by: g-re-g <123515925+g-re-g@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Michael Davis 685cd383a3
Surround with line-endings on `ms<ret>` (#4571)
This change makes `ms<ret>` work similarly to `t<ret>` and related
find commands: when the next event is a keypress of Enter, surround
the selection with the document's line-endings.
1 year ago
Pascal Kuthe 4dcf1fe66b
rework positioning/rendering and enable softwrap/virtual text (#5420)
* rework positioning/rendering, enables softwrap/virtual text

This commit is a large rework of the core text positioning and
rendering code in helix to remove the assumption that on-screen
columns/lines correspond to text columns/lines.

A generic `DocFormatter` is introduced that positions graphemes on
and is used both for rendering and for movements/scrolling.
Both virtual text support (inline, grapheme overlay and multi-line)
and a capable softwrap implementation is included.

fix picker highlight

cleanup doc formatter, use word bondaries for wrapping

make visual vertical movement a seperate commnad

estimate line gutter width to improve performance

cache cursor position

cleanup and optimize doc formatter

cleanup documentation

fix typos

Co-authored-by: Daniel Hines <d4hines@gmail.com>

update documentation

fix panic in last_visual_line funciton

improve soft-wrap documentation

add extend_visual_line_up/down commands

fix non-visual vertical movement

streamline virtual text highlighting, add softwrap indicator

fix cursor position if softwrap is disabled

improve documentation of text_annotations module

avoid crashes if view anchor is out of bounds

fix: consider horizontal offset when traslation char_idx -> vpos

improve default configuration

fix: mixed up horizontal and vertical offset

reset view position after config reload

apply suggestions from review

disabled softwrap for very small screens to avoid endless spin

fix wrap_indicator setting

fix bar cursor disappearring on the EOF character

add keybinding for linewise vertical movement

fix: inconsistent gutter highlights

improve virtual text API

make scope idx lookup more ergonomic

allow overlapping overlays

correctly track char_pos for virtual text

adjust configuration

deprecate old position fucntions

fix infinite loop in highlight lookup

fix gutter style

fix formatting

document max-line-width interaction with softwrap

change wrap-indicator example to use empty string

fix: rare panic when view is in invalid state (bis)

* Apply suggestions from code review

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

* improve documentation for positoning functions

* simplify tests

* fix documentation of Grapheme::width

* Apply suggestions from code review

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

* add explicit drop invocation

* Add explicit MoveFn type alias

* add docuntation to Editor::cursor_cache

* fix a few typos

* explain use of allow(deprecated)

* make gj and gk extend in select mode

* remove unneded debug and TODO

* mark tab_width_at #[inline]

* add fast-path to move_vertically_visual in case softwrap is disabled

* rename first_line to first_visual_line

* simplify duplicate if/else

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Ole Krüger 4eca4b3079
Support goto-declaration LSP command (#5646) 1 year ago
dependabot[bot] 75eeda69e7
build(deps): bump indoc from 1.0.8 to 2.0.0 (#5742)
Bumps [indoc](https://github.com/dtolnay/indoc) from 1.0.8 to 2.0.0.
- [Release notes](https://github.com/dtolnay/indoc/releases)
- [Commits](https://github.com/dtolnay/indoc/compare/1.0.8...2.0.0)

---
updated-dependencies:
- dependency-name: indoc
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 year ago
alice 8b25f44f05
build(deps): bump toml from 0.6.0 to 0.7.0 (#5726) 1 year ago
Jonathan LEI 86ae81ec5d
Use filename completer on run-shell-command (#5729) 1 year ago
Miguel Madrid-Mencía d2d3024337
Fix clippy 1.67 warnings (#5697) 1 year ago
ds-cbo 67a287dd81
keymap: Test backslash escaping in commands 1 year ago
Pascal Kuthe e83ce72240 refactor: don't deserialize &str from toml
The new version of the `toml` crate is based on `toml_edit` and does
not support zero copy deserialization anymore. So we need to deserialize
`String` instead of `&str` in the keympa
1 year ago
dependabot[bot] 52d854fa62 build(deps): bump toml from 0.5.10 to 0.6.0
Bumps [toml](https://github.com/toml-rs/toml) from 0.5.10 to 0.6.0.
- [Release notes](https://github.com/toml-rs/toml/releases)
- [Commits](https://github.com/toml-rs/toml/compare/toml-v0.5.10...toml-v0.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
dependabot[bot] 64ec0256d3
build(deps): bump which from 4.3.0 to 4.4.0 (#5655)
Bumps [which](https://github.com/harryfei/which-rs) from 4.3.0 to 4.4.0.
- [Release notes](https://github.com/harryfei/which-rs/releases)
- [Commits](https://github.com/harryfei/which-rs/compare/4.3.0...4.4.0)

---
updated-dependencies:
- dependency-name: which
  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>
1 year ago
Pascal Kuthe 361a834486
Fix selecting a changed file in global search (#5639) 1 year ago
Ivan Tham a20a96abdc
Remove apply_transaction helper (#5598) 1 year ago
Pascal Kuthe 0e5159ceca
Fix panic for noop selecting join (#5579) 1 year ago
Pascal Kuthe 7868e5f2d8
highlight non-bar cursors (#5575) 1 year ago
Gokul Soumya 5c7db7aed5 Replace menu::Item::{row, label} with format() 1 year ago
Gokul Soumya b2837ff3be Minimize allocation when converting table rows to string 1 year ago
Gokul Soumya 7a76c6cbba Use upstream implementation of table column calculation
Changed in a68e38e59e.
1 year ago
Gokul Soumya 9aafcb2b9a Reuse table in picker 1 year ago
gibbz00 deae13f404
Primary cursor colors by mode (#5130)
* (theme) feat: mode based primary cursor colors

* docs/themes: mode based primary cursor colors
1 year ago
mejo13 e7e47fd542
Add command to rotate view backward (#5356) 1 year ago
Nikodem Rabuliński 3cf5216dbd
Commit to history after executing a command from the palette (#5294) 1 year ago
greg-enbala 60f84be40c
Separate jump behavior from increment/decrement (#4123)
increment/decrement (C-a/C-x) had some buggy behavior where selections
could be offset incorrectly or the editor could panic with some edits
that changed the number of characters in a number or date. These stemmed
from the automatic jumping behavior which attempted to find the next
date or integer to increment. The jumping behavior also complicated the
code quite a bit and made the behavior somewhat difficult to predict
when using many cursors.

This change removes the automatic jumping behavior and only increments
or decrements when the full text in a range of a selection is a number
or date. This simplifies the code and fixes the panics and buggy
behaviors from changing the number of characters.
1 year ago
Itay123 d3e0f18c89
Added opening files in the background with A-ret shortcut (#4435) 1 year ago
Pascal Sommer 75dfaff338
Add some function documentations (#5360) 1 year ago
Dylan Bulfin c4b0eb8356
Fix autocompletion for paths with period (#5175)
* Bug fix

Updated bug fix

* Simplified conditionals

* Switched to use path separator constant
1 year ago
Lorenzo Albano b7ca0581d8
Store new config on application in :config-reload (#5431)
After changes in #5239, the loaded configuration wasn't stored,
resulting in a success message even if the instance kept the previous
configuration values.
1 year ago
Ethan Kiang 0dbee9590b
Fix language config reload logic (#5381) 1 year ago
dependabot[bot] a895a4e53a
build(deps): bump arc-swap from 1.5.1 to 1.6.0 (#5375)
Bumps [arc-swap](https://github.com/vorner/arc-swap) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/vorner/arc-swap/releases)
- [Changelog](https://github.com/vorner/arc-swap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vorner/arc-swap/compare/v1.5.1...v1.6.0)

---
updated-dependencies:
- dependency-name: arc-swap
  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>
1 year ago
dependabot[bot] d6d6267378
build(deps): bump once_cell from 1.16.0 to 1.17.0 (#5373)
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.16.0 to 1.17.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.16.0...v1.17.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>
1 year ago
Gabriel Dinner-David 1b1755240d
fix(commands): extend_line to proper line when count and current line selected (#5288) 1 year ago
Nick c9ed42cdec
Add a status line element that shows just the basename of the file (#5318) 1 year ago
iobtl 6c95411488
Expand `~` when parsing file paths in `:open` (#5329) 1 year ago
willful759 9d15b85209
Reload language config with `:config-reload` (#5239) 1 year ago
Triton171 5f2fe5fca5
Fix erroneous indent between closers of auto-pairs (#5330)
inserting a newline between 2 closers of an auto-pair.
1 year ago
alois31 eb4ec32710
Fix opening new files (#5278)
Commit 1b89d3e535 introduced a regression
where opening a new file would no longer work, because attempting to
canonicalize its path would lead to a "No such file or directory"
error. Fall back to opening a new file when encountering an error to
fix this case.
1 year ago
Nick 24c3b00d10
Avoid trailing `s` in message when only 1 file is opened (#5189) 1 year ago
jliaoh df1830ef28
mouse operations respect scrolloff (#5255) 1 year ago
DylanBulfin 1107296ca9
Add command to merge consecutive ranges in selection (#5047) 1 year ago
Jack Allison 1b89d3e535
Add file picker dialogue when opening a directory with :o (#2707) 1 year ago
dependabot[bot] 38fd20c858
build(deps): bump indoc from 1.0.7 to 1.0.8 (#5226)
Bumps [indoc](https://github.com/dtolnay/indoc) from 1.0.7 to 1.0.8.
- [Release notes](https://github.com/dtolnay/indoc/releases)
- [Commits](https://github.com/dtolnay/indoc/compare/1.0.7...1.0.8)

---
updated-dependencies:
- dependency-name: indoc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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>
1 year ago
Jonathan LEI 24cd7f6adf Make prompt suggestions greyed out 1 year ago
Alex Kladov e6a2df8c79
Better sorting in picker in case of ties (#5169) 1 year ago
Eric Thorburn b12c65678a
Print the binary required by the debug adapter (#5195)
This commit addresses issue 5193, where the author
requested that the name of the binary needed is printed along
with the rest of the health information.

This commit adds a format! macro which formats in the name of the
binary and then it will be printed along with the rest of the
debug information. The value in cmd is referenced to the call
to which, and then consumed upon the call to format!
1 year ago
Blaž Hrastnik ec9aa66902
Remove redraw to fix build 1 year ago
Sebastian Zivota 5c4a9cba9a
Restore deleted goto_pos function (#5164) 1 year ago
Roberto Vidal f916915b53
add redraw command (#4354)
* add redraw command

* update docs

* Update helix-term/src/commands/typed.rs

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

* update docs

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Michael Davis 42ad1a9e04
Select diagnostic range in goto_*_diag commands (#4713)
This roughly matches the behavior of the diagnostic picker: when
jumping to a diagnostic with `[d`/`]d`/`[D`/`]D`, the range of the
diagnostic is selected instead of the start point.
1 year ago
Michael Davis 2a60de74f9 workspace symbols: Default to empty Vec on None
A language server might send None as the response to workspace symbols.
We should treat this as the empty Vec rather than the server sending
an error status. This fixes the interaction with gopls which uses
None to mean no matching symbols.
1 year ago
Michael Davis 35cf972ce4 DynamicPicker: Reset idle timeout on refresh
If the new results shown by the picker select a file that hasn't been
previewed before, the idle timeout would not trigger highlighting on
that file. With this change, we reset the idle timeout and allow that
file to be highlighted on the next idle timeout event.
1 year ago
Michael Davis a7daa02346 DynamicPicker: Use idle-timeout as debounce
This change uses the idle-timeout event to trigger fetching new results
in the DynamicPicker, so idle-timeout becomes a sort of debounce. This
prevents querying the language server overly aggressively.
1 year ago
Gokul Soumya d1f717eb8d Re-request workspace symbols on keypress in picker
Most language servers limit the number of workspace symbols that
are returned with an empty query even though all symbols are
supposed to be returned, according to the spec (for perfomance
reasons). This patch adds a workspace symbol picker based on a
dynamic picker that allows re-requesting the symbols on every
keypress (i.e. when the picker query text changes). The old behavior
has been completely replaced, and I have only tested with
rust-analyzer so far.
1 year ago
Gokul Soumya 914d294499 Add DynamicPicker for updating options on every key 1 year ago
Gokul Soumya c64debc741 Add force_score() for scoring picker items without optimizations 1 year ago
Michael Davis db939801eb
Improve error message handling for theme loading failures (#5073)
The error messages for a theme that failed to be deserialized (or
otherwise failed to load) were covered up by the context/with_context
calls:

* The log message for a bad theme configured in config.toml would only
  say "Failed to deserilaize theme"
* Selecting a bad theme via :theme would show "Theme does not exist"

With these changes, we let the TOML deserializer errors bubble up, so
the error messages can now say the line number of a duplicated
key - and that key's name - when a theme fails to load because of a
duplicated key.

Providing a theme which does not exist to :theme still gives a helpful
error message: "No such file or directory."
1 year ago
Alexander Schlögl 0b96021643
Add `:pipe-to` typable command that ignores shell output (#4931) 1 year ago
Michael Davis cdc54f50a2
Reset mode when changing buffers (#5072)
* Reset mode when changing buffers

This is similar to the change in
e4c9d4082a139aac3aea4506918171b96e81f5b9: reset the editor to normal
mode when changing buffers. Usually the editor is already in normal
mode but it's possible to setup insert-mode keybindings that change
buffers.

* Move normal mode entering code to Editor

This should be called internally in the Editor when changing documents
(Editor::switch) or changing focuses (Editor::focus).
1 year ago
Pascal Kuthe 70d78123b9
properly handle detachted git worktrees (#5097) 1 year ago
Jummit 2ea20a23e2
Fix LSP completions ignoring auto-completion option (#5042) 1 year ago
Matouš Dzivjak 8abed3bd78
feat(lsp): pass client_info on initialization (#4904)
Pass client name ('helix') and client version (version / git hash)
to LSP server on initialization.
1 year ago
ath3 6798a6651f
Only write newlines in menu selection popup if the lsp returns detail (#4902) 1 year ago
Pascal Kuthe af532147c9
Add command/keybinding to jump between hunks (#4650)
* add command and keybding to jump to next/prev hunk

* add textobject for change

* Update helix-vcs/src/diff.rs

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

* select entire hunk instead of first char

* fix selection range

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Narazaki Shuji 453a75a373
fix: align view after jumplist_picker (#3743)
* Add `View::ensure_cursor_in_view_center` to adjust view after searching and jumping

Also `offset_coodrs_to_in_view` was refactored to reduce duplicated position calculations.

* Fix a wrong offset calculation in `offset_coords_to_in_view_center`

It ignored `scrolloff` if `centering` is false.
1 year ago
Michael Davis 2077f5e26a
Apply completion edits to all cursors (#4496)
Completion edits - either basic `insert_text` strings or structured
`text_edit`s - are assumed by the LSP spec to apply to the current
cursor (or at least the trigger point). We can use the range (if any)
and text given by the Language Server to create a transaction that
changes all ranges in the current selection though, allowing auto-
complete to affect multiple cursors.
1 year ago
nosa 7210c58a51
Change default TS object bindings (#3782)
* Change default TS object bindings

Changes 'match inside/around' bindings for:
- type definition from `c` to `t`
- comments from `o` to `c`
- tests from `t` to `T`

Also changes those for the `]` / `[` bindings.

* Update docs for changed keybinds

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Michael Davis bcdb475b71
Fix transaction composition order in History::changes_since (#4981)
* Add a undo/redo split test case for crossing branches

* history: Switch up/down transaction chaining order

The old code tends to work in practice because, usually, either up_txns
or down_txns are empty. When both have contents though, we can run into
a panic trying to compose them all since they will disagree on the
length of the text. This fixes the panic test case in the parent
commit.
1 year ago
lesleyrs 39ce82b7a5
Add Ctrl-i alias for Windows (#4961) 1 year ago
sigmaSd 4960c41f18
feat(lsp): add support for lsp Diagnostic{}.data (#4935) 1 year ago
Michael Davis 8291654326
reload_all: Ensure view is synced with doc history before reload (#4965) 1 year ago
Tshepang Mbambo a8a54be6bc
Fix nightly clippy lints (#4954) 1 year ago
Pascal Kuthe 5a3ff74221
Show (git) diff signs in gutter (#3890)
* Show (git) diff signs in gutter (#3890)

Avoid string allocation when git diffing

Incrementally diff using changesets

refactor diffs to be provider indepndent and improve git implementation

remove dependency on zlib-ng

switch to asynchronus diffing with similar

Update helix-vcs/Cargo.toml

fix toml formatting

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

fix typo in documentation

use ropey reexpors from helix-core

fix crash when creating new file

remove useless use if io::Cursor

fix spelling mistakes

implement suggested improvement to repository loading

improve git test isolation

remove lefover comments

Co-authored-by: univerz <univerz@fu-solution.com>

fixed spelling mistake

minor cosmetic changes

fix: set self.differ to None if decoding the diff_base fails

fixup formatting

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

reload diff_base when file is reloaded from disk

switch to imara-diff

Fixup formatting

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

Redraw buffer whenever a diff is updated.

Only store hunks instead of changes for individual lines to easily allow
jumping between them

Update to latest gitoxide version

Change default diff gutter position

Only update gutter after timeout

* update diff gutter synchronously, with a timeout

* Apply suggestions from code review

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

* address review comments and ensure lock is always aquired

* remove configuration for redraw timeout

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Michael Davis 4802f26a23 Add a test case for undo/redo across splits 1 year ago
Michael Davis 9a9e462183 Call View::apply within Document::append_changes_to_history 1 year ago
Michael Davis 4d1f5389f9 Revert "Don't apply transactions to Views in undo/redo"
This reverts commit fd00f3a70e.
1 year ago
Michael Davis df5457a6e7 Remove eager application of transactions to all views 1 year ago
Filipe Azevedo f0f295a667
reload-all: Only update viewport when view focuses on the doc (#4901) 1 year ago
Michael Davis 2271c3aed9
Clear line on `<ret>` when line is all whitespace (#4854)
This matches the insert-mode behavior for Vim and Kakoune: if the
current line is empty except for whitespace, `<ret>` should insert a
line ending at the beginning of the line, moving any indentation to the
next line.
1 year ago
Jonathan LEI 1d21683321
Exit select mode on surround commands (#4858) 1 year ago
Michael Davis a3f321a531 Follow parent links when calculating changes since a revision
The 'revisions' field on History can't be treated as linear: each
Revision in the revisions Vec has a parent link and an optional child
link. We can follow those to unroll the recent history.
1 year ago
Michael Davis 4a103db622 Apply inversions to Views on undo/redo
When using undo/redo, the history revision can be decremented. In that
case we should apply the inversions since the given revision in
History::changes_since. This prevents panics with jumplist operations
when a session uses undo/redo to move the jumplist selection outside
of the document.
1 year ago
Michael Davis fd00f3a70e Don't apply transactions to Views in undo/redo
View::apply should only be called by EditorView after
42e37a571e. This change removes the
duplicate calls within undo/redo which could cause a panic.
1 year ago
Michael Davis 94eb3de776 Add test case that panics on undo
This case panics since undo/redo call View::apply and here, the edit
that moves the jumplist selection out-of-bounds is not yet applied when
View::apply is called in undo/redo. View::apply should only be called
by the EditorView now.
1 year ago
Michael Davis 42e37a571e
Apply transactions to all views (#4733)
* Add a test case for updating jumplists across windows

* Apply transactions to all views on history changes

This ensures that jumplist selections follow changes in documents, even
when there are multiple views (for example a split where both windows
edit the same document).

* Leave TODOs for cleaning up View::apply

* Use Iterator::reduce to compose history transactions

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

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
1 year ago
Michael Davis 9059c65a53
lsp: Check server provider capabilities (#3554)
Language Servers may signal that they do not support a method in
the initialization result (server capabilities). We can check these
when making LSP requests and hint in the status line when a method
is not supported by the server. This can also prevent crashes in
servers which assume that clients do not send requests for methods
which are disabled in the server capabilities.

There is an existing pattern the LSP client module where a method
returns `Option<impl Future<Output = Result<_>>>` with `None` signaling
no support in the server. This change extends this pattern to the rest
of the client functions. And we log an error to the statusline for
manually triggered LSP calls which return `None`.
1 year ago
Bob 1db01caec7
remove duplicated shell calls (#3465) 1 year ago
Michael Davis 8102c3224f
Limit the number of items in the jumplist (#4750)
Previously, jumplists could grow unchecked. Every transaction is
applied to jumplist selections to ensure that they are up to date
and within document bounds, so this would cause every edit to become
more expensive as jumplist lengths increased throughout a session.
Setting a maximum number of entries limits the cost.

Vim and Neovim limit their jumplists:

* b298fe6cba/src/structs.h (L141)
* e8cc489acc/src/nvim/mark_defs.h (L57)

Notably, Kakoune does not. In Kakoune, changes are applied to jumplist
entries lazily as you hit `<C-o>`/`<C-i>` though, so Kakoune doesn't
have the same growing cost concerns. Kakoune also does not have a
concept of a View which limits the cost further.

Vim and Neovim limit to 100. This seems unreasonably high to me so I've
set this to 30 to start. We can increase if this is problematically
low.
1 year ago
Michael Davis bbde897ac3
Select new pasted text in normal mode only (#4824)
d6323b7cbc changed the behavior of paste
to select the newly inserted text. This is preferrable in normal mode
because it's useful to be able to act on the new text. This behavior
is worse for insert or select mode though:

* In insert mode, the cursor ends up on the last character of the newly
  selected text, so further typing inserts text before the last
  character.
* In select mode, the current selection is replaced with the new text
  selection which doesn't extend the current selection. With this
  change, the selection is extended to include the new text.

This aligns the behavior more closely with Kakoune, but it's
coincidental instead of intentional: Kakoune doesn't implement
bracketed paste (AFAIK) which causes this behavior in insert mode,
and Kakoune doesn't have a select mode.
1 year ago
A-Walrus 2f9ca3840a
Add preview for scratch buffers in buffer picker (#3454) 1 year ago
Filipe Azevedo 8dac863a5b
Add `:reload-all` command (#4663) 1 year ago
Lennard Hofmann 0e23e4f882
Make `r<tab>` and `f<tab>` work (#4817)
Previously, commands such as `r<tab>` (replace with tab) or `t<tab>`
(select till tab) had no effect. This is because `KeyCode::Tab` needs
special treatment (like `KeyCode::Enter`).
1 year ago
Blaž Hrastnik 7e99087fa3
minor: render_diagnostics doesn't require &self either 1 year ago
Blaž Hrastnik a640ab6b1f
Avoid repeatedly loading config 1 year ago
Michael Davis 8be2d1dcbf
Handle language server termination (#4797)
This change handles a language server exiting. This was a UX sore-spot:
if a language server crashed, Helix did not recognize the exit and
continued to send requests to it. All requests would timeout since they
would not receive responses. This would also hold-up Helix closing
itself down since it would try to gracefully shutdown the server which
is implemented in the LSP spec as a request.

We could attempt to automatically restart the language server on crash.
I left this for future work since that change will need to be slightly
complicated: it will need to cover the case of a language server
repeatedly crashing.
1 year ago
Michael Davis 89efb4f711
lsp: Resolve completion item asynchronously on idle-timeout (#4781)
d7d0d5ffb7 resolves completion items on
the idle-timeout event. The `Completion::resolve_completion_item`
function blocks on the LSP request though, which blocks the compositor
and in turn blocks the event loop. So until the language server returns
the resolved completion item, Helix is unable to respond to keypresses
or other LSP messages.

This is typically ok since the resolution request is fast but for some
language servers this can be problematic, and ideally we shouldn't be
blocking like this anyways.

When receiving a `completionItem/resolve` request, the Volar server
sends a `workspace/configuration` request to Helix and blocks itself
on the response, leading to a deadlock. Eventually the resolve request
times out within Helix but Helix is locked up and unresponsive in that
window.

This change resolves the completion item without blocking the
compositor.
1 year ago
Austen Adler 1569d2000b
Select surrounding characters when using match/surround (m) mode (#4752)
Co-authored-by: Austen Adler <agadler@austenadler.com>
1 year ago
ChrHorn 322e957ea1
Remove prefix filtering from autocomplete menu (#4578)
PR #4134 switched the autocomplete menu from alphabetical to fuzzy
sorting. This commit removes the still existing filtering by prefix and
should enable full fuzzy sorting of the autocomplete menu.

closes #3084, #1807

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
1 year ago
Michael Davis c6b83368b3
Capture word parts while calculating shellwords (#4632)
This fixes an edge case for completing shellwords. With a file
"a b.txt" in the current directory, the sequence `:open a\<tab>`
will result in the prompt containing `:open aa\ b.txt`. This is
because the length of the input which is trimmed when replacing with
completion is calculated on the part of the input which is parsed by
shellwords and then escaped (in a separate operation), which is lossy.
In this case it loses the trailing backslash.

The fix provided here refactors shellwords to track both the _words_
(shellwords with quotes and escapes resolved) and the _parts_ (chunks
of the input which turned into each word, with separating whitespace
removed). When calculating how much of the input to delete when
replacing with the completion item, we now use the length of the last
part.

This also allows us to eliminate the duplicate work done in the
`ends_with_whitespace` check.
1 year ago
Michael Davis 6eec14ee37
Use key-sequence format for command palette keybinds (#4712)
The text within the command palette used a custom format to display
the keybinding for a command. This change switches to the key sequence
format that we use for pending keys and macros.
1 year ago
Pascal Kuthe 4b89177e53
sort fuzzy matches with equal score by length in picker (#4698) 1 year ago
Blaž Hrastnik fe11ae2218
minor: Simplify some command code 2 years ago
Blaž Hrastnik a3173c2280
minor: cloning filter and using count() is wasteful here 2 years ago
Blaž Hrastnik df6d04425d
fix build 2 years ago
Armin Ronacher 392a018aeb
Add command to add word boundaries to search (#4322)
* Add command to add word boundaries to search

* Calculate string capacity before building
2 years ago
Manos Mertzianis 77be98c783
Popup scrollbar (#4449)
* init

* cargo fmt

* optimisation of the scrollbar render both for Menu and Popup. Toggling off scrollbar for Popup<Menu>, since Menu has its own

* rendering scroll track

* removed unnecessary cast

* improve memory allocation

* small correction
2 years ago
ath3 3b7760dfb0
Refactor blackhole register (#4504) 2 years ago
Gaurav Tyagi 91ff903bf3
Add global error/warning count statusline element (#4569) 2 years ago
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.
2 years ago
wes adams fd585c1ee4
Statusline indicator to show number of selected chars (#4682)
Co-authored-by: wes adams <wadams@grayshift.com>
2 years ago
asvln 1f72d34249 rename description for `goto_line_end_newline` 2 years ago
asvln 7468fa28fd add `extend_prev_word_end` command 2 years ago
Bruce Hopkins bc0a3037ea
feat(commands): increment by range (#4418) 2 years ago
Blaž Hrastnik 758bace221
fix test compilation 2 years ago
Blaž Hrastnik 264a455c18
Move terminal out of compositor 2 years ago
Blaž Hrastnik 00d7b18097
This term specific behavior really doesn't belong to compositor 2 years ago
Blaž Hrastnik b2e7171fed
Drop terminal interaction in compositor.size() 2 years ago
Blaž Hrastnik d4f5cab7b5
Re-enable format_selections for a single selection range 2 years ago
Matthias Deiml dee5b2a983
Add LSP workspace command picker (#3140)
* Add workspace command picker

* Make command typable

* Add optional argument to lsp-workspace-command
2 years ago
Marko Klobučar Ledinšćak d8e9c85f5e
`error!` on unknown `CompletionItemKind` (#4658) 2 years ago
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
2 years ago
Blaž Hrastnik c94feed83d
core: Move state into the history module 2 years ago
Blaž Hrastnik 13126823f8
lsp: Support insertReplace
Fixes #4473
2 years ago
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.
2 years ago
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.
2 years ago
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.
2 years ago
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
2 years ago
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`.
2 years ago
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.
2 years ago
Blaž Hrastnik c2c1280f02
Resolve a bunch of upcoming clippy lints 2 years ago
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>
2 years ago
Jonathan LEI db3383c76e
Exit select mode on replace commands (#4554) 2 years ago
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.
2 years ago
Armin Ronacher 8584b38cfb
Correctly handle escaping in completion (#4316)
* Correctly handle escaping in completion

* Added escaping tests
2 years ago
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>
2 years ago
Matthew Toohey 00cf12f571
fix: make `scroll` aware of tabs and wide characters (#4519) 2 years ago
Matthias Deiml 5e256e4a98
Make shell_impl concurrent (#3180) 2 years ago
Poliorcetics c58e1729ce
fix: Never create automatic doc popups outside of Insert mode (#4456) 2 years ago
Michael Davis cefdface3b
Include colons for typable commands in command palette (#4495)
Before:

    Goto next buffer. [buffer-next]

After:

    Goto next buffer. [:buffer-next]
2 years ago
Dario Oddenino 6752c7d347
Trim quotes and braces from paths in goto_file_impl (#4370)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2 years ago
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
2 years ago
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>
2 years ago
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
2 years ago
Michał Zabielski 65edf9c198
fix: repeating repeat operator (#4450) 2 years ago
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
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.
2 years ago
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.
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
Alexis (Poliorcetics) Bourget 3aea33a415 nit: move an allocation to happen after a `continue`, making sure it's
not done for nothing
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
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.
2 years ago
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>
2 years ago
Pascal Kuthe 9af7c1c9f3 Sort by fixed diagnostics/is_preffered within codeaction categories 2 years ago
Pascal Kuthe 189aa0bfcf never sort menu items when no fuzzy matching is possible 2 years ago
Pascal Kuthe dc3527f52d use permalink to vscode repo 2 years ago
Pascal Kuthe 8d8b5d6624 use stable sort instead of allocating new vectors 2 years ago
Pascal Kuthe c70d762a7b sort autocompletins by fuzzy match 2 years ago
Pascal Kuthe 8673c1ec0c sort codeaction by their kind instead of alphabetically 2 years ago
Skyler Hawthorne 6a0b450f55
Fix multi byte auto pairs (#4024)
* Fix test::print for Unicode

The print function was not generating correct translations when
the input has Unicode (non-ASCII) in it. This is due to its use of
String::len, which gives the length in bytes, not chars.

* Fix multi-code point auto pairs

The current code for auto pairs is counting offsets by summing the
length of the open and closing chars with char::len_utf8. Unfortunately,
this gives back bytes, and the offset needs to be in chars.

Additionally, it was discovered that there was a preexisting bug where
the selection was not computed correctly in the case that the cursor
was:

1. a single grapheme in width
2. this grapheme was more than one char
3. the direction of the cursor is backwards
4. a secondary range

In this case, the offset was not being added into the anchor. This was
fixed.

* migrate auto pairs tests to integration

* review comments
2 years ago