Commit graph

2141 commits

Author SHA1 Message Date
Michael Davis
a066815833 Enable the enhanced keyboard protocol if supported 2023-02-28 12:35:52 +09:00
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.
2023-02-28 12:35:52 +09:00
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>
2023-02-28 10:24:06 +09:00
Yusuf Bera Ertan
e5af0f1d49
build(nix): update flake to use flake-parts and nci flake-parts module 2023-02-25 06:27:13 +03:00
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>
2023-02-20 13:00:44 +09:00
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>
2023-02-20 13:00:00 +09:00
Guillaume
78a1e2db60
feat: show current language when no argument is provided (#5895) 2023-02-16 23:48:35 +09:00
Triton171
a1a6d5f334
Replace incorrect usages of tab_width with indent_width. (#5918) 2023-02-16 23:47:59 +09:00
Erasin
b7fb52d0e4
fix: decode lsp url for workspace_diagnostics_picker (#6016) 2023-02-16 23:33:54 +09:00
Jonathan LEI
9368ac76b3
Ignore invalid file URIs from LSP (#6000) 2023-02-16 14:17:18 +09:00
Pascal Kuthe
c332b16855
ignore case while filtering completions (#6008) 2023-02-16 10:16:51 +09:00
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.
2023-02-16 10:15:25 +09:00
Pascal Kuthe
715c4b24d9
Fix crash in goto_window_center at EOF (#5987) 2023-02-14 13:00:54 -06:00
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.
2023-02-13 11:44:31 +09:00
A-Walrus
8b09b00942
Add :toggle-option command (#4085)
This command toggles the value of boolean options
2023-02-13 11:40:31 +09:00
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.
2023-02-11 16:05:23 +09:00
Gokul Soumya
1562b5ce67 Create popup rect instead of using raw values 2023-02-11 16:05:23 +09:00
Gokul Soumya
0f844ef191 Refactor our Markdown construction in completion doc 2023-02-11 16:05:23 +09:00
Gokul Soumya
937825e8fc Rename completion doc popup area variables 2023-02-11 16:05:23 +09:00
Gokul Soumya
8e9c329952 Use early return in rendering completion doc 2023-02-11 16:05:23 +09:00
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.
2023-02-11 15:50:01 +09:00
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>
2023-02-10 13:52:57 -06:00
lesleyrs
af1157f37c
Add exit code to command failed msg (#5898) 2023-02-10 11:56:56 -06:00
Colton Clemmer
ea3293b4da
Split modification indicator from file statusline elements (#4731) 2023-02-10 11:34:18 -06:00
Pascal Kuthe
8a3ec443f1
Fix new clippy lints (#5892) 2023-02-09 16:27:08 -06:00
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.
2023-02-09 23:28:33 +09:00
Blaž Hrastnik
8a602995fa
Address new clippy lints 2023-02-09 11:44:14 +09:00
Pascal Kuthe
e474779c87
bump msrv to 1.63 (#5570)
* bump msrv to 1.63

* resolve new complex type clippy lints
2023-02-09 11:24:31 +09:00
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>
2023-02-08 10:09:19 -06:00
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.
2023-02-07 12:43:48 +09:00
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.
2023-02-04 13:20:23 -08:00
William Etheredge
f7bd7b5eaf
Add :character-info command (#4000) 2023-02-03 08:24:46 -06:00
Pascal Kuthe
350535208f
always commit to history when pasting (#5790) 2023-02-02 14:56:52 -05:00
Skyler Hawthorne
a5233cf5ad disable lsp in integration tests 2023-02-02 14:53:18 -05:00
Filipe Azevedo
8ba0a46274
add picker: current view dir (#4666) 2023-02-02 14:51:11 -05:00
Dylan Bulfin
61e1e6160a
Removing C-j and C-k from completion menu navigation (#5070) 2023-02-02 14:49:17 -05:00
Pascal Kuthe
f0c2e898b4
add substring matching options to picker (#5114) 2023-02-02 14:48:16 -05:00
Gokul Soumya
e31943c4c4
Tabulate buffer picker contents (#5777) 2023-02-02 14:32:05 -05:00
Pascal Kuthe
2949bb018c
fix position translation at EOF with softwrap (#5786) 2023-02-02 13:04:41 -05:00
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>
2023-02-02 11:14:02 -06:00
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.
2023-02-01 16:29:48 -05:00
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>
2023-02-01 02:03:19 +09:00
Ole Krüger
4eca4b3079
Support goto-declaration LSP command (#5646) 2023-01-31 05:38:53 -05:00
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>
2023-01-30 17:47:30 -06:00
alice
8b25f44f05
build(deps): bump toml from 0.6.0 to 0.7.0 (#5726) 2023-01-30 08:49:26 -06:00
Jonathan LEI
86ae81ec5d
Use filename completer on run-shell-command (#5729) 2023-01-30 08:48:27 -06:00
Miguel Madrid-Mencía
d2d3024337
Fix clippy 1.67 warnings (#5697) 2023-01-27 09:43:46 -06:00
ds-cbo
67a287dd81
keymap: Test backslash escaping in commands 2023-01-25 09:31:58 -06:00
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
2023-01-24 12:50:46 -06:00
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>
2023-01-24 12:50:46 -06:00
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>
2023-01-23 17:25:49 -06:00
Pascal Kuthe
361a834486
Fix selecting a changed file in global search (#5639) 2023-01-23 11:18:44 -06:00
Ivan Tham
a20a96abdc
Remove apply_transaction helper (#5598) 2023-01-21 12:13:43 -06:00
Pascal Kuthe
0e5159ceca
Fix panic for noop selecting join (#5579) 2023-01-18 15:28:47 -06:00
Pascal Kuthe
7868e5f2d8
highlight non-bar cursors (#5575) 2023-01-19 00:28:45 +08:00
Gokul Soumya
5c7db7aed5 Replace menu::Item::{row, label} with format() 2023-01-18 14:19:32 +09:00
Gokul Soumya
b2837ff3be Minimize allocation when converting table rows to string 2023-01-18 14:19:32 +09:00
Gokul Soumya
7a76c6cbba Use upstream implementation of table column calculation
Changed in a68e38e59e.
2023-01-18 14:19:32 +09:00
Gokul Soumya
9aafcb2b9a Reuse table in picker 2023-01-18 14:19:32 +09:00
gibbz00
deae13f404
Primary cursor colors by mode (#5130)
* (theme) feat: mode based primary cursor colors

* docs/themes: mode based primary cursor colors
2023-01-18 14:18:49 +09:00
mejo13
e7e47fd542
Add command to rotate view backward (#5356) 2023-01-17 16:15:21 -06:00
Nikodem Rabuliński
3cf5216dbd
Commit to history after executing a command from the palette (#5294) 2023-01-16 10:41:22 -06:00
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.
2023-01-16 10:15:23 -06:00
Itay123
d3e0f18c89
Added opening files in the background with A-ret shortcut (#4435) 2023-01-16 16:18:13 +09:00
Pascal Sommer
75dfaff338
Add some function documentations (#5360) 2023-01-10 20:11:43 -06:00
Dylan Bulfin
c4b0eb8356
Fix autocompletion for paths with period (#5175)
* Bug fix

Updated bug fix

* Simplified conditionals

* Switched to use path separator constant
2023-01-09 11:25:19 +09:00
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.
2023-01-08 09:30:38 -06:00
Ethan Kiang
0dbee9590b
Fix language config reload logic (#5381) 2023-01-03 07:24:48 -06:00
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>
2023-01-02 21:29:23 -06:00
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>
2023-01-02 21:07:25 -06:00
Gabriel Dinner-David
1b1755240d
fix(commands): extend_line to proper line when count and current line selected (#5288) 2022-12-31 08:23:55 -06:00
Nick
c9ed42cdec
Add a status line element that shows just the basename of the file (#5318) 2022-12-31 08:18:14 -06:00
iobtl
6c95411488
Expand ~ when parsing file paths in :open (#5329) 2022-12-29 10:13:06 -06:00
willful759
9d15b85209
Reload language config with :config-reload (#5239) 2022-12-29 09:51:23 -06:00
Triton171
5f2fe5fca5
Fix erroneous indent between closers of auto-pairs (#5330)
inserting a newline between 2 closers of an auto-pair.
2022-12-29 09:23:40 -06:00
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.
2022-12-24 07:50:39 -06:00
Nick
24c3b00d10
Avoid trailing s in message when only 1 file is opened (#5189) 2022-12-23 08:13:05 -06:00
jliaoh
df1830ef28
mouse operations respect scrolloff (#5255) 2022-12-22 20:30:33 -06:00
DylanBulfin
1107296ca9
Add command to merge consecutive ranges in selection (#5047) 2022-12-22 20:27:20 -06:00
Jack Allison
1b89d3e535
Add file picker dialogue when opening a directory with :o (#2707) 2022-12-22 20:23:34 -06:00
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>
2022-12-19 17:22:27 -06:00
Jonathan LEI
24cd7f6adf Make prompt suggestions greyed out 2022-12-17 13:59:05 -06:00
Alex Kladov
e6a2df8c79
Better sorting in picker in case of ties (#5169) 2022-12-17 13:30:43 -06:00
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!
2022-12-17 13:03:18 -06:00
Blaž Hrastnik
ec9aa66902
Remove redraw to fix build 2022-12-15 22:23:06 +09:00
Sebastian Zivota
5c4a9cba9a
Restore deleted goto_pos function (#5164) 2022-12-15 22:20:26 +09:00
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>
2022-12-15 17:59:34 +09:00
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.
2022-12-15 17:57:31 +09:00
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.
2022-12-15 17:52:44 +09:00
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.
2022-12-15 17:52:44 +09:00
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.
2022-12-15 17:52:44 +09:00
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.
2022-12-15 17:52:44 +09:00
Gokul Soumya
914d294499 Add DynamicPicker for updating options on every key 2022-12-15 17:52:44 +09:00
Gokul Soumya
c64debc741 Add force_score() for scoring picker items without optimizations 2022-12-15 17:52:44 +09:00
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."
2022-12-15 17:49:49 +09:00
Alexander Schlögl
0b96021643
Add :pipe-to typable command that ignores shell output (#4931) 2022-12-11 20:06:24 -06:00
Michael Davis
cdc54f50a2
Reset mode when changing buffers (#5072)
* Reset mode when changing buffers

This is similar to the change in
e4c9d4082a: 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).
2022-12-12 00:04:08 +09:00
Pascal Kuthe
70d78123b9
properly handle detachted git worktrees (#5097) 2022-12-11 19:20:34 +09:00
Jummit
2ea20a23e2
Fix LSP completions ignoring auto-completion option (#5042) 2022-12-08 22:02:34 -06:00
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.
2022-12-08 21:57:03 -06:00
ath3
6798a6651f
Only write newlines in menu selection popup if the lsp returns detail (#4902) 2022-12-08 21:55:15 -06:00
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>
2022-12-06 23:18:33 +09:00
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.
2022-12-06 11:16:08 +09:00
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.
2022-12-06 10:29:40 +09:00
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>
2022-12-06 10:13:41 +09:00
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.
2022-12-03 12:09:08 +09:00
lesleyrs
39ce82b7a5
Add Ctrl-i alias for Windows (#4961) 2022-12-02 08:02:29 -06:00
sigmaSd
4960c41f18
feat(lsp): add support for lsp Diagnostic{}.data (#4935) 2022-12-02 10:18:45 +09:00
Michael Davis
8291654326
reload_all: Ensure view is synced with doc history before reload (#4965) 2022-12-02 10:18:32 +09:00
Tshepang Mbambo
a8a54be6bc
Fix nightly clippy lints (#4954) 2022-12-01 10:37:38 -06:00
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>
2022-12-01 17:35:23 +09:00
Michael Davis
4802f26a23 Add a test case for undo/redo across splits 2022-11-30 01:15:20 +09:00
Michael Davis
9a9e462183 Call View::apply within Document::append_changes_to_history 2022-11-30 01:15:20 +09:00
Michael Davis
4d1f5389f9 Revert "Don't apply transactions to Views in undo/redo"
This reverts commit fd00f3a70e.
2022-11-30 01:15:20 +09:00
Michael Davis
df5457a6e7 Remove eager application of transactions to all views 2022-11-30 01:15:20 +09:00
Filipe Azevedo
f0f295a667
reload-all: Only update viewport when view focuses on the doc (#4901) 2022-11-26 14:40:43 -06:00
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.
2022-11-25 11:40:48 +09:00
Jonathan LEI
1d21683321
Exit select mode on surround commands (#4858) 2022-11-24 11:07:19 +09:00
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.
2022-11-24 10:57:12 +09:00
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.
2022-11-24 10:57:12 +09:00
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.
2022-11-24 10:57:12 +09:00
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.
2022-11-24 10:57:12 +09:00
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>
2022-11-23 12:28:49 +09:00
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`.
2022-11-22 11:52:23 +09:00
Bob
1db01caec7
remove duplicated shell calls (#3465) 2022-11-22 10:55:46 +09:00
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.
2022-11-22 10:54:50 +09:00
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.
2022-11-21 11:49:44 +09:00
A-Walrus
2f9ca3840a
Add preview for scratch buffers in buffer picker (#3454) 2022-11-20 19:58:35 -06:00
Filipe Azevedo
8dac863a5b
Add :reload-all command (#4663) 2022-11-20 12:39:26 -06:00
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`).
2022-11-19 11:08:03 -06:00
Blaž Hrastnik
7e99087fa3
minor: render_diagnostics doesn't require &self either 2022-11-19 15:41:55 +09:00
Blaž Hrastnik
a640ab6b1f
Avoid repeatedly loading config 2022-11-19 15:41:03 +09:00
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.
2022-11-19 13:14:36 +09:00
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.
2022-11-19 03:27:46 +09:00
Austen Adler
1569d2000b
Select surrounding characters when using match/surround (m) mode (#4752)
Co-authored-by: Austen Adler <agadler@austenadler.com>
2022-11-17 20:46:03 -06:00
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>
2022-11-17 10:16:03 +09:00
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.
2022-11-17 10:00:48 +09:00
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.
2022-11-17 09:58:54 +09:00
Pascal Kuthe
4b89177e53
sort fuzzy matches with equal score by length in picker (#4698) 2022-11-16 17:28:20 -06:00
Blaž Hrastnik
fe11ae2218
minor: Simplify some command code 2022-11-16 18:14:30 +09:00
Blaž Hrastnik
a3173c2280
minor: cloning filter and using count() is wasteful here 2022-11-16 18:14:30 +09:00
Blaž Hrastnik
df6d04425d
fix build 2022-11-15 23:34:00 +09:00
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
2022-11-15 23:16:27 +09:00
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
2022-11-15 23:15:52 +09:00
ath3
3b7760dfb0
Refactor blackhole register (#4504) 2022-11-15 23:14:18 +09:00
Gaurav Tyagi
91ff903bf3
Add global error/warning count statusline element (#4569) 2022-11-14 19:46:07 -06:00
Michael Davis
c74b97447f
Fix range offsets for multiple shell insertions (#4619)
d6323b7cbc introduced a regression for
shell commands like `|`, `!`, and `<A-!>` which caused the new
selections to be incorrect. This caused a panic when piping (`|`)
would cause the new range to extend past the document end.

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

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

* Make command typable

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

* removing digits lower-bound, permitting spacer

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

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

* linenr width based on document line count

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

* lint rolling; removing unnecessary type parameter lifetime

* merge change resolution

* reformat code

* rename row_styler to style; add int_log resource

* adding spacer to gutters default; updating book config entry

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

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

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

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

* Inherit selection directions on paste

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

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

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

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

* Ensure cursor is in view on window change

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

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

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

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

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

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

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

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

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

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

    Goto next buffer. [buffer-next]

After:

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

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

```
Theme name not provided
```

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

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

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

* add docs

* update the docs
2022-10-26 11:58:49 +09:00
Michał Zabielski
65edf9c198
fix: repeating repeat operator (#4450) 2022-10-25 21:15:46 -05:00
GabrielDertoni
9fae4b8118 fix: terminal freezing on shell_insert_output
This bug occurs on `shell_insert_output` and `shell_append_output`
commands.

The previous implementation would create a child process using the Rust
stdlib's `Command` builder. However, when nothing should be piped in
from the editor, the default value for `stdin` would be used. According
to the Rust stdlib documentation that is `Stdio::inherit` which will
make the child process inherit the parent process' stdin. This would
cause the terminal to freeze.

This change will set the child process' stdin to `Stdio::null` whenever
it doesn't pipe it. In the `if` statement where this change was made
there was an extra condition for windows that I am not sure if would
require some special treatment.
2022-10-25 20:24:44 -05:00
Michael Davis
c47ca33137
Render diagnostics in the file picker preview (#4324)
This is mostly for the sake of the diagnostics pickers: without
rendering the diagnostic styles, it's hard to tell where the entries
in the picker are pointing to.
2022-10-25 21:03:35 +09:00
Michael Davis
d7d0d5ffb7
lsp: Resolve completion items missing documentation on idle (#4406)
Some language servers may not send the `documentation` field if it
is expensive to compute. Clients can request the missing field with
a completionItem/resolve request.

In this change we use the idle-timeout event to ensure that the current
completion item is resolved.
2022-10-22 10:04:50 +09:00
Alexis (Poliorcetics) Bourget
34389e1d54 nit: Do less allocations in ui::menu::Item::label implementations
This complicates the code a little but it often divides by two the number of allocations done by
the functions. LSP labels especially can easily be called dozens of time in a single menu popup,
when listing references for example.
2022-10-21 07:42:33 -05:00
Alexis (Poliorcetics) Bourget
3aea33a415 nit: move an allocation to happen after a continue, making sure it's
not done for nothing
2022-10-21 07:42:33 -05:00
Skyler Hawthorne
5a848344a9
fix: write-all crash (#4384)
When we do auto formatting, the code that takes the LSP's response and applies
the changes to the document are just getting the currently focused view and
giving that to the function, basically always assuming that the document that
we're applying the change to is in focus, and not in a background view.

This is usually fine for a single view, even if it's a buffer in the
background, because it's still the same view and the selection will get updated
accordingly for when you switch back to it. But it's obviously a problem for
when there are multiple views, because if you don't have the target document in
focus, it will ask the document to update the wrong view, hence the crash.

The problem with this is picking which view to apply any selection change to.
In the absence of any more data points on the views themselves, we simply pick
the first view associated with the document we are saving.
2022-10-21 16:43:22 +09:00
Nimrod
bad49ef2d0
Fix unexpected behavior in delete_word_backward and delete_word_forward (#4392) 2022-10-21 15:08:37 +09:00
Skyler Hawthorne
f486f34ebe
flush writes on force quit (#4397)
When force quitting, we need to block on the pending writes to ensure
that write commands succeed before exiting, and also to avoid a crash
when all the views are gone before the auto format call returns from
the LS.
2022-10-21 13:28:29 +09:00
Charlie Groves
7e29ee6dae
Autosave all when the terminal loses focus (#3178)
* Autosave all when the terminal loses focus

* Correct comment on focus config

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

* Need a block_try_flush_writes in all quit_all paths

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-10-21 10:35:02 +09:00
Pascal Kuthe
9af7c1c9f3 Sort by fixed diagnostics/is_preffered within codeaction categories 2022-10-21 10:03:00 +09:00
Pascal Kuthe
189aa0bfcf never sort menu items when no fuzzy matching is possible 2022-10-21 10:03:00 +09:00
Pascal Kuthe
dc3527f52d use permalink to vscode repo 2022-10-21 10:03:00 +09:00
Pascal Kuthe
8d8b5d6624 use stable sort instead of allocating new vectors 2022-10-21 10:03:00 +09:00
Pascal Kuthe
c70d762a7b sort autocompletins by fuzzy match 2022-10-21 10:03:00 +09:00
Pascal Kuthe
8673c1ec0c sort codeaction by their kind instead of alphabetically 2022-10-21 10:03:00 +09:00
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
2022-10-21 09:22:20 +09:00
Michael Davis
66238e8556 Silence dead_code warning on AppBuilder::with_config
This function is not currently used but is likely to be useful in
the future, so this change silences the dead_code warning.
2022-10-21 08:43:15 +09:00
Michael Davis
313579d27c Remove language-server configuration in integration tests
This change removes language server configuration from the default
languages.toml config for integration tests. No integration-tests
currently depend on the availability of a language server but if any
future test needs to, it may provide a language server configuration
by passing an override into the `test_syntax_conf` helper.

Language-servers in integration tests cause false-positive failures
when running integration tests in GitHub Actions CI. The Windows
runner appears to have `clangd` installed and all OS runners have
the `R` binary installed but not the `R` language server package.
If a test file created by `tempfile::NamedTempFile` happens to have a
file extension of `r`, the test will most likely fail because the
R language server will fail to start and will become a broken pipe,
meaning that it will fail to shutdown within the timeout, causing a
false-positive failure. This happens surprisingly often in practice.

Language servers (especially rust-analyzer) also emit unnecessary
log output when initializing, which this change silences.
2022-10-21 08:43:15 +09:00
Michael Davis
1243db11a5 Use helix_view::apply_transaction in integration-tests
`helix_view::apply_transaction` closes over `Document::apply` and
`View::apply` to ensure that jumplist entries are updated when a
document changes from a transaction. `Document::apply` shouldn't
be called directly - this helper function should be used instead.
2022-10-21 08:43:15 +09:00
Matouš Dzivjak
4cff625054
chore(view): remove indent_unit helper fn (#4389) 2022-10-20 17:05:04 -05:00
Matouš Dzivjak
eee8362015
fix(commands): no last picker error (#4387) 2022-10-20 15:50:54 -05:00
Blaž Hrastnik
78c0cdc519
Merge pull request #2267 from dead10ck/fix-write-fail
Write path fixes
2022-10-20 23:11:22 +09:00
Fisher Darling
4174b25b3d
Pretty print tree-sitter-subtree expression (#4295) 2022-10-19 17:17:50 -05:00
Skyler Hawthorne
756253b43f fix tree_sitter_scopes 2022-10-19 00:01:00 -04:00
Skyler Hawthorne
e645804b0a Editor::flush_writes returns an error 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
52ba550098 Use flush_writes in application.close() 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
55b50d9e83 Seems like this flush is unnecessary 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
b0212b3611 Deduplicate flush_writes 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
30c93994b5 Use a single save_queue on the editor 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
beb3427bfb improve app close failure display 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
bf378e71b0 fix tests 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
31d1bbfddb review comments 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
3f07885b35 document should save even if formatter fails 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
b530a86d1f remove Callback::Compositor variant
To reduce likelihood of accidental discarding of important callbacks
2022-10-18 22:31:39 -04:00
Skyler Hawthorne
b3fc31a211 move language server refresh to document saved event handler 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
af03df3413 fix write scratch buffer to file 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
18c32118b1 Save text in document saved events, use in status message 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
f82a551b98 Rename doc save event names to past tense 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
57de4e6251 various fixes in write-all path 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
d544376590 reset idle timer for all events 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
e5fd5e2a9c fix panic when view of pending write is closed 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
8c667ef8de factor editor event handling into function 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
aaa1450678 fix write-quit with auto format
write-quit will now save all files successfully even when there is auto
formatting
2022-10-18 22:31:39 -04:00
Skyler Hawthorne
c9418582d2 fix modified status with auto format 2022-10-18 22:31:38 -04:00
Skyler Hawthorne
cb23399dee improve reliability of shutdown 2022-10-18 22:31:38 -04:00
Skyler Hawthorne
b8a07f7d15 add conditional noop render back
It makes it much slower without stubbing this out
2022-10-18 22:31:38 -04:00
Skyler Hawthorne
69c9e44ef2 update write-quit to wait for saves 2022-10-18 22:31:38 -04:00
Skyler Hawthorne
e1f7bdb1d2 fix buffer-close 2022-10-18 22:31:38 -04:00
Skyler Hawthorne
83b6042b97 fix(write): do not set new path on document until write succeeds
If a document is written with a new path, currently, in the event that
the write fails, the document still gets its path changed. This fixes
it so that the path is not updated unless the write succeeds.
2022-10-18 22:31:38 -04:00
Skyler Hawthorne
a5a93182cd fix: buffer-close ensuring writes
Make sure buffer-close waits for the document to finish its writes.
2022-10-18 22:31:38 -04:00
Skyler Hawthorne
d706194597 chore(write): serialize write operations within a Document
The way that document writes are handled are by submitting them to the
async job pool, which are all executed opportunistically out of order. It
was discovered that this can lead to write inconsistencies when there
are multiple writes to the same file in quick succession.

This seeks to fix this problem by removing document writes from the
general pool of jobs and into its own specialized event. Now when a
user submits a write with one of the write commands, a request is simply
queued up in a new mpsc channel that each Document makes to handle its own
writes. This way, if multiple writes are submitted on the same document,
they are executed in order, while still allowing concurrent writes for
different documents.
2022-10-18 22:31:38 -04:00
Jonathan LEI
1a772d1b67
Fix deleting word from end of buffer (#4328) 2022-10-18 19:53:58 -05:00
Roberto Vidal
1f74cf45d4
display tree sitter scopes in a popup (#4337) 2022-10-19 00:00:00 +05:30
Philipp Mildenberger
d17ffc47f0
Use the same WalkBuilder configuration for the global search file picker as the default file picker (#4334)
Skip searching .git in global search, similar to how file picker skips listing files in .git.
2022-10-18 22:58:16 +05:30
A-Walrus
8bbddf90ff Replace in_bounds with calculation of end_indent
Instead of repeatedly checking if it is in_bounds, calculate the
max_indent beforehand and just loop. I added a debug_assert to "prove"
that it never tries drawing out of bounds.
2022-10-18 00:38:16 +09:00
A-Walrus
1de02a147c Only draw indent guides within bounds
Better performance, and otherwise very long lines with lots of tabs
will wrap around the u16 and come back on the other side, messing up
the beginning skip_levels.
2022-10-18 00:38:16 +09:00
A-Walrus
2c36e33e0a Make skip_levels a u8 2022-10-18 00:38:16 +09:00
A-Walrus
3ba665d804 Fix rendering of lines longer than 2^16
Before things would be cast to u16 earlier than needed, which would
cause problems for insanely long lines (longer than 2^16 ~ 65 thousand)
2022-10-18 00:38:16 +09:00
Gokul Soumya
4e691d6247
Change diagnostic picker keybind to <space>d (#4229)
Also changes workspace diagnostic picker bindings to <space>D and
changes the debug menu keybind to <space>g, the previous diagnostic
picker keybind. This brings the diagnostic picker bindings more in
line with the jump to next/previous diagnostic bindings which are
currently on ]d and [d.
2022-10-17 16:45:42 +09:00
Michael Davis
5f4f171b73
Fix debug assertion for diagnostic sort order (#4319)
The debug assertion that document diagnostics are sorted incorrectly
panics for cases like `[161..164, 162..162]`. The merging behavior
in the following lines that relies on the assertion only needs the
input ranges to be sorted by `range.start`, so this change simplifies
the assertion to only catch violations of that assumption.
2022-10-17 01:22:04 +05:30
ZJPzjp
0e8e7cae3b
fix :insert-output doc: inserting output **before** each selection (#4286) 2022-10-15 11:07:42 -05:00
Poliorcetics
45e038f4d5
nit: remove a String allocation that is immediately used as an &str (#4277) 2022-10-14 17:35:00 -05:00
Nathaniel Graham
e80beaa7b0
Changed Selection Yank Message (#4275)
Co-authored-by: Nathaniel Graham <ngraham@protonmail.com>
2022-10-14 12:51:15 -05:00
Michael Davis
e16c632760
Apply transactions to the jumplist for undo/redo (#4227)
Undo/redo/earlier/later call `Document::apply_impl` which applies
transactions to the document. These transactions also need to be
applied to the view as in 0aedef0.
2022-10-13 00:57:40 +09:00
Armin Ronacher
7f75458e6f
Fix some commands not showing names in palette (#4223) 2022-10-12 09:02:10 -05:00
Graic
68909dcef4
Fix append cursor location when selection anchor is at end of document (#4147) 2022-10-12 08:34:35 -05:00
Brian Orwe
f4d96b2ca3
Fix confusion with using --hsplit --vsplit on startup at same time (#4202) 2022-10-11 09:25:42 -04:00
Alexis (Poliorcetics) Bourget
b58899bc8e fix: remove unneeded allocations when calling helix_view::Info::new 2022-10-11 15:47:11 +09:00