Commit graph

2513 commits

Author SHA1 Message Date
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
Christian Schneider
fcded6ce1e
Trim trailing colons from paths to allow copy/pasting git grep -n output (#9963)
Co-authored-by: Christian Schneider <schneider@search.ch>
2024-12-17 13:02:06 -06:00
Pascal Kuthe
1badd9e434
implement snippet tabstop support 2024-12-17 13:34:40 -05:00
Pascal Kuthe
66fb1e67c0
add fallback onNextKey
adds a variant of on_next_key callbacks that are only called when no other
mapping matches a key
2024-12-17 13:34:40 -05:00
Pascal Kuthe
609c29bf7e
add DocumentFocusLost event 2024-12-17 13:34:40 -05:00
Pascal Kuthe
5537e68b5e
add changes and ghost_transaction to DocumentDidChange events 2024-12-17 13:34:40 -05:00
dependabot[bot]
312c64f0c2
build(deps): bump the rust-dependencies group with 10 updates (#12277)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-16 18:48:13 -06:00
Integral
250d9fa8fe
Avoid allocating the --help message (#12243) 2024-12-16 11:16:48 -06:00
Aaalibaba
3b36cf1a15
Expand tildes in :read command (#12271) 2024-12-16 11:10:35 -06:00
Takumi Matsuura
e14c346ee7
Fix panic in kill_to_end_of_line when handling multibyte characters (#12237) 2024-12-13 14:04:52 -06:00
TornaxO7
89a7cde2f0
Fix continuing comment token for first line (#12215) 2024-12-10 13:24:34 -06:00
TornaxO7
5005c14e99
Add config option for continue commenting (#12213)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2024-12-09 17:31:41 -06:00
Nikita Revenco
db1d84256f
fix: report correct amount of files opened and improved error message when Helix can't parse directory as file (#12199)
* feat: improve information on the amount of files loaded

* refactor: naming consitency Doc and not Buf

* fix: correct name of method

* chore: appease clippy

* feat: more human error information when Helix cannot start

* refatcor: use if guard on match arm
2024-12-08 20:14:29 +09:00
Michael Davis
28953ef40f
Simplify change_current_directory and remove extra allocs 2024-12-05 18:50:31 -05:00
Nikita Revenco
93deb1f6ae
feat: :cd - changes to the previous working directory (#12194)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2024-12-05 17:40:37 -06:00
Michael Davis
fd3e889927 Add integration tests for line comment continuation 2024-12-05 20:53:53 +09:00
Michael Davis
1e6fe00001 Trim all trailing whitespace on insert_newline 2024-12-05 20:53:53 +09:00
Ian Hobson
4c8175ca04 Draw each message line separately in draw_eol_diagnostic
`set_string_truncated` renders the entire string while ignoring
newlines, so if the diagnostic's message contains multiple lines it
produces messages like 'first linesecond line'.

To avoid these run-ons, this commit renders each line separately,
inserting double spaces for disambiguation.
2024-12-04 18:23:30 -06:00
Ian Hobson
715a13b2d3 Remove an incorrect comment
This was copied from the function above (set_style). I don't know enough
about the function to suggest an alternative.
2024-12-04 18:23:30 -06:00
Nikita Revenco
565bfbba25
feat: :cd with no args changes to home directory (#12042) 2024-12-04 18:09:33 -06:00
Tomasz Zurkowski
7a2afdc080
Show an error when formatter is not available (#12183) 2024-12-04 08:27:54 -06:00
Michael Davis
085c4fe4c8
docs: Eliminate improper use of "LSP" term
Sometimes we used "LSP" to mean "language server". This change
eliminates the improper "LSP" usage.

Ref https://github.com/helix-editor/helix/pull/12183#discussion_r1868436105
2024-12-03 18:29:44 -05:00
dependabot[bot]
cf81e15315
build(deps): bump the rust-dependencies group with 3 updates (#12181)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-02 18:27:49 -06:00
RoloEdits
5ba97ba41e
fix(clippy): clippy 1.83 lints (#12150) 2024-12-02 08:23:32 -06:00
Poliorcetics
0f4729289b
fix: Remove leftover debug println! (#12138)
Introduced in dc941d6d24
2024-11-27 20:05:18 +09:00
Milan Vaško
7676106960
Search selection with word boundary detection (#12126)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2024-11-26 13:30:53 -06:00
dependabot[bot]
80709cee61
build(deps): bump the rust-dependencies group with 4 updates (#12129)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-25 18:06:54 -06:00
RoloEdits
cbbeca6c52
fix(clippy): suppress unused lint on windows (#12107) 2024-11-22 08:10:11 -06:00