Commit graph

2540 commits

Author SHA1 Message Date
Michael Davis
c9dc940428
Fix byte/char indexing mix-up in path completion
The positions passed to `Transaction::change_by_selection` should be
character indexes. `edit_diff` is meant to track the number of
characters that should be deleted to erase the file name that has been
typed so far (if any). Mistakenly this was using `str::len` which is
the byte count. This fixes a bug that could cause more text to be
deleted than intended or a panic when completing a directory with
multi-byte characters like 'éclair'.

This change also moves the `edit_diff` binding out of the loop since
it's now performing some non-trivial work (counting characters, where
before it was just accessing the pre-computed number of bytes).
2025-01-29 10:05:21 -05:00
dependabot[bot]
98ddbf0086
build(deps): bump the rust-dependencies group with 2 updates (#12707)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-27 17:19:26 -06: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
kyfanc
9829ac0c02
Cycle through hover results from multiple language servers (#10122)
Co-authored-by: Vladyslav Karasov <36513243+cotneit@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-01-26 11:24:50 -06:00
Kristoffer Plagborg Bak Sørensen
7c907e66f4
feat: print helpful suggestion when using :{,r}sort incorrectly (#12585) 2025-01-26 10:39:19 -06:00
Michael Davis
360c6bb061
stdx: Replace RopeSliceExt::byte_to_next_char with ceil_char_boundary
The new `RopeSliceExt::ceil_char_boundary` from the parent commits can
be used to implement `RopeSliceExt::byte_to_next_char` when used with
`RopeSlice::byte_to_char`. That function had only one caller and that
caller will eventually disappear when we switch to Ropey v2 and drop
character indexing, so we can drop `byte_to_next_char` now and replace
its caller with `byte_to_char` plus `ceil_char_boundary`.

This change keeps the unit tests for `byte_to_next_char` and checks them
against a polyfill of `byte_to_char` plus `ceil_char_boundary` to ensure
that `byte_to_next_char`'s intended behavior is not changed.
2025-01-26 11:11:53 -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
Nikita Revenco
a63a2ad281
feat: specify custom lang server(s) for :lsp-stop and :lsp-restart (#12578)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-01-23 18:14:35 -06:00
Michael Davis
d4ade40983
Rename "file browser" => "file explorer"
Connects #11285
2025-01-23 18:17:56 -05:00
Michael Davis
9d6ea773e9
prompt: Cap anchor to line length in cursor calculation
This prevents a panic when using `C-w` on a long single-word prompt line
for example.

Connects #12036
2025-01-23 17:33:28 -05:00
Denys Rybalka
6b044aeb29
Add file browser (#11285) 2025-01-23 16:28:18 -06:00
Yomain
8af33108f6
fix: better display of prompts on long inputs (#12036) 2025-01-23 15:56:34 -06:00
TornaxO7
fa27ae16a7
Add path completion for multiple cursors (#12550) 2025-01-23 14:31:12 -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
168b11e091
feat: passing multile of the same files in the arguments places a cursor at each position (#12192)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-01-23 14:04:02 -06:00
Jose Alvarez
d123193902
Replace current file when loading in background from picker (#12605) 2025-01-23 12:49:20 -06:00
Michael Davis
ccdb710431
minor: Rename '*' at eof integration test to be more specific 2025-01-21 09:08:36 -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
janos-r
d4ee22b483
Generate a .deb file (#12453) 2025-01-16 17:37:53 -06: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
Nikita Revenco
e01775a667
fix: unable to detect Color completion item hex code for some LSPs (#12501)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-01-12 09:40:19 -06:00
Michael Davis
0f2ce303c5
Add directory name to :cd errors
For example `:cd README.md` would say "Not a directory" but would not
print the directory name. Now the error message includes some context
about the operation and requested directory.
2025-01-11 20:39:44 -05: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
dependabot[bot]
e698b20245
build(deps): bump the rust-dependencies group with 3 updates (#12437) 2025-01-06 19:34:21 -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
f80ae997f2
perf: cache Documents relative path (#12385) 2025-01-05 16:29:16 -06:00
RoloEdits
64b38d1a28
refactor(shellwords)!: change arg handling strategy (#11149) 2025-01-05 12:18:30 -06:00
Jean Abou Samra
9cc056e755
fix (hx --health): Don't print headers in white (#12355) 2024-12-29 10:38:28 -06:00
Michael Davis
073efe48f9
minor: Setup default keymap directly in xtask docgen
Instantiating EditorView is a lot of machinery which is unnecessary:
the default keymap is exposed through the `default` function in the
keymap module.
2024-12-28 21:42:09 -05:00
RoloEdits
19c91dfb80
fix: string literals with format args not in format! (#12354) 2024-12-28 07:44:16 -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
dependabot[bot]
a074129f9c
build(deps): bump the rust-dependencies group with 7 updates (#12327)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2024-12-25 10:05:50 -06: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
ba6e6dc3dd
Colors for items in the completion menu (#12299) 2024-12-20 10:16:15 -06:00
Nikita Revenco
355e381626
feat: use ui.text.directory for path completion item if its a folder (#12295) 2024-12-19 14:36:54 -06:00
Eduardo Rittner Coelho
9e4da4b950
Show parser availability in --health [LANG] (#12228) 2024-12-18 11:21:58 -06:00
Nikita Revenco
91a5d407da
Allow theming directory prompt completions (#12205) 2024-12-17 21:13:42 -06:00