Commit Graph

1096 Commits (8eec1e8d40fd974c7b7ddda5175680ae7298d04b)

Author SHA1 Message Date
Nikola Milenkovic 1157263f3f
Merge branch 'helix-editor:master' into master 2025-06-15 19:14:30 +02:00
Axlefublr 637274c4d4
Add `rotate_selections_{first,last}` commands (#13615) 2025-06-06 15:08:41 -05:00
Ryan Mehri 6c43dc4962
fix: trim whitespace up to the last selection on insert_newline (#13673) 2025-06-03 08:45:19 -05:00
Nikola Milenkovic 34051968e6
Merge branch 'helix-editor:master' into master 2025-06-02 10:51:34 +02:00
CalebLarsen 7dcddf98c6
Append changes to history on jumps (#13619)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-05-27 09:44:47 -05:00
Axlefublr 2fbe7fc5b5
fix(doc): missing capitalization of `goto_{next,prev}_tabstop` (#13616) 2025-05-26 08:48:32 -05:00
Nikola Milenkovic b8f1873296
Merge branch 'helix-editor:master' into master 2025-05-15 14:25:04 +02:00
Michael Davis aea53523dd
Replace tree-sitter with tree-house 2025-05-13 18:43:43 -04:00
Michael Davis c94fde8d1c
syntax: Move config types to a separate module 2025-05-13 18:30:21 -04:00
Nikola Milenkovic a6e25fb6f9
Merge branch 'helix-editor:master' into master 2025-05-07 13:24:39 +01:00
Daniel Bowring 69b9db2fbb
Add goto_column and extend_to_column commands (#13440) 2025-05-01 09:12:30 -05:00
Nikola Milenkovic 46dfbd0991 feat: implement buffer jumplist
j.a=":ab"
j.d=":rb"
j.0=":j 0"
j.1=":j 1"
j.2=":j 2"
j.3=":j 3"
j.4=":j 4"
2025-04-30 00:09:31 +01:00
Sumandora 99b57181d5
Improve auto completion for shell commands (#12883)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-04-27 14:04:56 -05:00
Dimitri Sabadie 29789f2a9f
Add support for extend_file_{start,end} (#11767) 2025-04-06 13:18:47 -05:00
Michael Davis 7e7a98560e
LSP: Eagerly decode request results in the client
Previously the `call` helper (and its related functions) returned a
`serde_json::Value` which was then decoded either later in the client
(see signature help and hover) or by the client's caller. This led to
some unnecessary boilerplate in the client:

    let resp = self.call::<MyRequest>(params);
    Some(async move { Ok(serde_json::from_value(resp.await?)?) })

and in the caller. It also allowed for mistakes with the types. The
workspace symbol request's calling code for example mistakenly decoded a
`lsp::WorkspaceSymbolResponse` as `Vec<lsp::SymbolInformation>` - one of
the untagged enum members (so it parsed successfully) but not the
correct type.

With this change, the `call` helper eagerly decodes the response to a
request as the `lsp::request::Request::Result` trait item. This is
similar to the old helper `request` (which has become redundant and has
been eliminated) but all work is done within the same async block which
avoids some awkward lifetimes. The return types of functions like
`Client::text_document_range_inlay_hints` are now more verbose but it is
no longer possible to accidentally decode as an incorrect type.

Additionally `Client::resolve_code_action` now uses the `call_with_ref`
helper to avoid an unnecessary clone.
2025-03-22 14:40:29 -04:00
Michael Davis 0efa8207d8
Rewrite command line parsing, add flags and expansions (#12527)
Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
2025-02-26 19:50:15 -06:00
may e1c7a1ed77
remove unnecessary allocations in switch_case (#12786) 2025-02-26 19:03:29 -06:00
Michael Davis 7bebe0a70e
Highlight file picker directories with 'ui.text.directory'
This applies the same styling as the parent commit to the file pickers.
2025-02-26 19:19:37 -05:00
Nik Revenco 682967d328
feat: Improve look of Global Search Picker (#12855)
Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-02-26 18:09:57 -06:00
Michael Davis e0da129727
Use custom titles for register select info boxes
Previously all register selection info boxes had "Registers" as the
title. That was particularly confusing for `copy_between_registers`
which presents two info boxes back-to-back.
2025-02-19 10:29:15 -05:00
Michael Davis 066e938ba0
Add `copy_between_registers` for interactive register copying 2025-02-02 20:49:25 -05:00
Michael Davis e882a750ea
commands: Eagerly clear autoinfo in select_register, insert_register
This causes the infobox to disappear even when you type a non-character
key like escape. For example `"<esc>` now clears the infobox where
before it was left hanging.
2025-02-02 20:45:25 -05:00
Michael Davis e9c16b7fc5
Use typable command doc when keybind provides no arguments
This improves the display of the keymap popup for example, so that if
you bind a key like `C-x = ":buffer-close"` under the `<space>` menu,
the infobox shows "Close the current buffer." rather than `:buffer-close
[]`.
2025-02-01 09:10:04 -05:00
Michael Davis 47f84d04ea
Set a statusline error for formatter errors in `:format` 2025-01-31 14:07:22 -05:00
Zi How Poh 0c8f0c0334
goto_diag: avoid wraparound by default (#12704) 2025-01-27 14:41:34 -06:00
Michael Davis 20151a5594
Move rope grapheme iterators from core to stdx 2025-01-27 09:24:40 -05:00
Michael Davis 0364521dca
goto_word: Skip keys with modifiers in both on-next-key blocks 2025-01-27 09:24:40 -05:00
Michael Davis f5f9f499cf
goto_word: Reject jump label characters with modifiers
Previously you could use `<A-a><A-b>` to jump to a label "ab". We should
not treat characters with modifiers the same as characters without.
With this change the `<A-a>` input exits out of the jumping on-next-key.

Fixes #12695
2025-01-27 08:49:03 -05:00
Michael Davis 4919058e90
Use RopeSliceExt floor/ceil functions for goto_file_impl search cap
This is a good example use-case of the `floor_char_boundary` and
`ceil_char_boundary` functions added in the parent commit. In the
single-width, single-selection case in `goto_file` we cap the search
to either the current line or 1000 bytes before or after the cursor
(whichever case comes earlier). That byte index might not lie on a
character boundary so it needs to be fixed to either the prior or
later boundary.
2025-01-26 11:10:50 -05:00
magackame 3fdd98979c
fix: `goto_file_impl` incorrect use of `slice` instead of `byte_slice` (#12673) 2025-01-25 12:38:35 -06:00
Darshan Kumawat 81708b70e6
doc: Document `mdm` and `mrm` for popup help (#12650) 2025-01-24 11:46:19 -06:00
Michael Davis d4ade40983
Rename "file browser" => "file explorer"
Connects #11285
2025-01-23 18:17:56 -05:00
Denys Rybalka 6b044aeb29
Add file browser (#11285) 2025-01-23 16:28:18 -06:00
Rolo 650af50c13 fix: typos 2025-01-23 15:18:16 -05:00
Rolo c1d382a532 fix(lints): clippy 1.84 2025-01-23 15:18:16 -05:00
Nikita Revenco ba4793fca0
fix: panic when pressing `*` after the end of the file (#12611)
* fix: panic when pressing `*` at the end of the file

chore: remove incorrect additions

* docs: add info comment

* test: add new syntax to add a selection at the final character

* test: `*` panics when after the last char

* test: move into a more appopriate module

* test: fix failing

* test: account for Windows test suite

* test: choose a different strategy for custom syntax

* test: do not modify the syntax

* style: remove newline

---------

Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-01-21 16:05:15 +09:00
Nikita Revenco 076d8bd173
fix: surprising behaviour when changing line above a comment (#12575)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-01-17 15:29:39 -06:00
Michael Davis 69068770c8
Add extra logging for external formatters and formatting errors
This should help debug formatting failures when using external
formatters in the future. Previously we didn't log anything when an
external formatter failed despite having a custom error type for it.
2025-01-17 11:00:34 -05:00
Michael Davis 4c41c5250c
Eliminate an unnecessary clone in insert_newline 2025-01-17 10:23:36 -05:00
Michael Davis 3318953bf6
minor: Use more exact allocations in `insert_newline`
This is partially a style commit:

* Pull more bindings out the `change_by_selection` closure like the
  line-ending string and the comment tokens used for continuation.
* Prefer `Editor::config` to `Document`'s config.

The rest is changes to places where `insert_newline` may allocate.

The first is to move `new_text` out of the `change_by_selection`
closure, reusing it between iterations. This is not necessarily always
an improvement as we need to clone the text for the return type of the
closure. `SmartString`'s `From<String>` implementation reuses the
allocation when the string is too long to inline and drops it if it is
short enough to inline though which can be wasteful. `From<&String>`
clones the string's allocation only when it is too long to be inlined,
so we save on allocations for any `new_text` short enough to be inlined.

The rest is changes to `new_text.reserve_exact`. Previously calls to
this function in this block mixed up character and byte indexing by
treating the length of the line-ending as 1. `reserve_exact` takes a
number of bytes to reserve and that may be 2 when `line_ending` is a
CRLF. A call to `reserve_exact` is also added to the branch used when
continuing line comments.
2025-01-15 10:57:03 -05:00
Michael Davis 4bd17e542e
Fix offset tracking in `insert_newline`
#12177 changed `insert_newline`'s behavior to trim any trailing
whitespace on a line which came before a cursor. `insert_newline` would
previously never delete text. Even the whitespace stripping behavior in
#4854 worked by inserting text - a line ending at the beginning of the
line. `global_offs`, a variable that tracks the number of characters
inserted between iterations over the existing selection ranges, was not
updated to also account for text deleted by the trimming behavior,
causing cursors to be offset by the amount of trailing space deleted
and causing panics in some cases.

To fix this we need to subtract the number of trimmed whitespace
characters from `global_offs`. `global_offs` must become an `isize`
(was a `usize`) because it may become negative in cases where a lot of
trailing whitespace is trimmed. Integration tests have been added for
each of these cases.

Fixes #12461
Fixes #12495
Fixes #12539
2025-01-15 10:36:29 -05:00
TornaxO7 60bff8feee
Fix `open_{below, above}` behaviour with multiple cursors (#12465) 2025-01-13 08:14:30 -06:00
rhogenson 931dd9c1dc
Fix a typo in join_selections (#12452)
Co-authored-by: Rose Hogenson <rosehogenson@posteo.net>
2025-01-08 08:42:41 -06:00
Michael Davis 917174e546
Fix blank buffer picker preview on doc with no views
Reproduction:

* `hx`
* Open any file in a split (`<space>f` and choose anything with `<C-v>`)
* Close the split with `<C-w>q`
* Open up the buffer picker and look the file you opened previously

Previously the preview was empty in this case because the Document's
`selections` hashmap was empty and we returned early, giving `None`
instead of a FileLocation. Instead when the Document is not currently
open in any view we can show the document but with no range highlighted.
2025-01-07 15:11:15 -05:00
Michael Davis 217818681e
Revert "refactor(shellwords)!: change arg handling strategy (#11149)"
This reverts commit 64b38d1a28.
2025-01-06 12:39:53 -05:00
RoloEdits 64b38d1a28
refactor(shellwords)!: change arg handling strategy (#11149) 2025-01-05 12:18:30 -06:00
Michael Davis c262fe41ab
Consistently replace line-endings in paste/replace commands
Previously we replaced line-endings in pasted text to the document
line-ending for some values in paste commands. We missed the `repeat`
values in paste though and didn't do any replacement in the replace
command.

Along with this change I've refactored the replace command to avoid
intermediary collections. We previously eagerly collected the values
from the input register as a `Vec<String>` but we can avoid both of
those conversions and only allocate for the conversion to a `Tendril`.
We can also switch from `str::repeat` to a manual implementation to
avoid the intermediary conversion to a String - this avoids an extra
allocation in the common case (i.e. no count).

Fixes #12329
2024-12-25 11:38:44 -05:00
Michael Davis 4f63a46e14
minor: Remove redundant condition in shell pipe trimming
`output.ends_with('\n')` implies `!output.is_empty()`

Connects #11183
2024-12-22 09:42:37 -05:00
Nikita Revenco ac4c017165
feat: autohelp for delete, replace and add surrounds (#12262) 2024-12-22 08:17:44 -06:00
Nikita Revenco 91a5d407da
Allow theming directory prompt completions (#12205) 2024-12-17 21:13:42 -06:00