Commit Graph

163 Commits (2c9f5b3efb72f4ab62fe29ddaa1c0871bca9b01d)

Author SHA1 Message Date
Itay123 d3e0f18c89
Added opening files in the background with A-ret shortcut (#4435) 2023-01-16 16:18:13 +09:00
Alex Kladov e6a2df8c79
Better sorting in picker in case of ties (#5169) 2022-12-17 13:30:43 -06: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 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
A-Walrus 2f9ca3840a
Add preview for scratch buffers in buffer picker (#3454) 2022-11-20 19:58:35 -06:00
Pascal Kuthe 4b89177e53
sort fuzzy matches with equal score by length in picker (#4698) 2022-11-16 17:28:20 -06: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
Pascal Kuthe 1a87cbd508 remove filterting with C-space from picker 2022-10-11 12:25:28 +09:00
Pascal Kuthe 7af599e0af Treat space as a seperator instead of a character in fuzzy picker 2022-10-11 12:25:28 +09:00
Blaž Hrastnik a85e386298
picker: Highlight the document on idle timeout 2022-10-11 09:53:55 +09:00
Poliorcetics e8f0886b21
chore: remove unneeded attribute after MSRV bump to 1.61 (#3961) 2022-09-25 08:12:33 -05:00
Pascal Kuthe 4133f1f424
Document MSRV policy (#3913) 2022-09-23 15:58:00 +09:00
Frojdholm 4c9f144dac
fix: Recalculate completion when going through prompt history (#3193)
* fix: Recalculate completion when going through prompt history

* Update completion when the prompt line is changed

It should not be possible to update the line without also updating the
completion since the completion holds an index into the line.

* Fix Prompt::with_line recalculate completion

with_line was the last function where recalculate completion had to be
done manually. This function now also recalculates the completion so
that it's impossible to forget.

* Exit selection when recalculating completion

Keeping the selection index when the completion has been recalculated
doesn't make sense. This clears the selection automatically, removing
most needs to manually clear it.

* Remove &mut on save_filter

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-09-01 01:26:21 +09:00
Charlie Groves f38ede8631
Add bracketed paste (#3233) 2022-08-29 09:48:49 +09:00
Gokul Soumya 634b6d455f
Add custom event type replacing crossterm's Event (#3169)
Ported over from 61365dfbf3 in the `gui` branch. This will allow
adding our own events, most notably an idle timer event (useful
for adding debounced input in [dynamic pickers][1] used by interactive
global search and workspace symbols).

[1]: https://github.com/helix-editor/helix/pull/3110

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-08-09 10:31:26 +09:00
Bob 2a8d38c27b
support toggling pickers' preview panel (#3021)
* support toggling pickers' preview panel

* add doc for toggling preview
2022-07-18 10:11:25 +09:00
Joe b26e7e2e8f
Add live preview to theme picker (#1798)
* Add theme picker with live preview

* Add live theme preview to :theme command

* cargo fmt

* Fix clippy warnings

* Remove picker variant

* Remove unused import

* Cleanup

* Change current_theme to last_theme

* Fix accidental comment flash deletion

* Typo

* Remove theme cache

* Add some comments

* Refactor some theme handling

TIL flatmap on Option is called  and_then

* Remove unnecessary renames

* Constrain last_theme theme preview lifecycle

* Switch to bitflag implementation

* Better handling of last_theme

* Sort theme names

* Better memory juggling

* Missed a branch

* Remove name from theme, switch bitand to &

* cargo fmt

* Update helix-view/src/editor.rs

* Switch boolean to enum

* Remove bitflag impl

* cargo fmt

* Remove un-needed type arg

* cargo fmt
2022-07-05 19:44:16 +09:00
ChrHorn 9f43dbc45d
Highlight whole row in picker menus (#2939) 2022-07-02 17:29:46 +05:30
Gokul Soumya 6e2aaed5c2
Reuse menu::Item trait in picker (#2814)
* Refactor menu::Item to accomodate external state

Will be useful for storing editor state when reused by pickers.

* Add some type aliases for readability

* Reuse menu::Item trait in picker

This opens the way for merging the menu and picker code in the
future, since a picker is essentially a menu + prompt. More
excitingly, this change will also allow aligning items in the
picker, which would be useful (for example) in the command palette
for aligning the descriptions to the left and the keybinds to
the right in two separate columns.

The item formatting of each picker has been kept as is, even though
there is room for improvement now that we can format the data into
columns, since that is better tackled in a separate PR.

* Rename menu::Item::EditorData to Data

* Call and inline filter_text() in sort_text() completion

* Rename diagnostic picker's Item::Data
2022-07-02 13:21:27 +02:00
Falco Hirschenberger ed89f8897e
Add workspace and document diagnostics picker (#2013)
* Add workspace and document diagnostics picker

fixes #1891

* Fix some of @archseer's annotations

* Add From<&Spans> impl for String

* More descriptive parameter names.

* Adding From<Cow<str>> impls for Span and Spans

* Add new keymap entries to docs

* Avoid some clones

* Fix api change

* Update helix-term/src/application.rs

Co-authored-by: Bjorn Ove Hay Andersen <bjrnove@gmail.com>

* Fix a clippy hint

* Sort diagnostics first by URL and then by severity.

* Sort diagnostics first by URL and then by severity.

* Ignore missing lsp severity entries

* Add truncated filepath

* Typo

* Strip cwd from paths and use url-path without schema

* Make tests a doctest

* Better variable names

Co-authored-by: Falco Hirschenberger <falco.hirschenberger@itwm.fraunhofer.de>
Co-authored-by: Bjorn Ove Hay Andersen <bjrnove@gmail.com>
2022-06-30 18:16:18 +09:00
Gokul Soumya 8e8367eea6
Refactor Margin for fine grained control (#2727) 2022-06-22 01:52:08 +09:00
Gokul Soumya 8ad0b83e30 Make indent guides configurable 2022-06-21 18:43:25 +02:00
Blaž Hrastnik 10415a8069
Bump dependencies, allow retain_mut for now 2022-05-29 11:10:49 +09:00
kyrime bfc4ff4dcf
Add theme key for picker separator (#2523)
Co-authored-by: ky <>
2022-05-22 10:24:51 +09:00
Michael Davis e04bb8b891
address rust 1.61.0 clippy lints (#2514) 2022-05-20 12:16:11 +09:00
Omnikar e6b865ed0b allow whitespace to be rendered
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2022-04-20 11:37:23 +09:00
Rohan Jain 5d61631507
Resolve conflicts between prompt/picker bindings (#1792)
Currently, the picker's re-using a few bindings which are also present
in the prompt. This causes some editing behaviours to not function on
the picker.

**Ctrl + k** and **Ctrl + j**
This should kill till the end of the line on prompt, but is overridden
by the picker for scrolling. Since there are redundancies (`Ctrl + p`,
`Ctrl + n`), we can remove it from picker.

**Ctrl + f** and **Ctrl + b**
This are used by the prompt for back/forward movement. We could modify
it to be Ctrl + d and Ctrl + u, to match the `vim` behaviour.
2022-03-31 16:51:11 +09:00
Blaž Hrastnik 4940db3e2d
Make truncate_start a builder method instead 2022-03-28 11:02:49 +09:00
Blaž Hrastnik 92bb312f0f
Make line a private property 2022-03-28 11:02:26 +09:00
Blaž Hrastnik 83b3272166
This doesn't need to be mut 2022-03-28 11:02:07 +09:00
Rohan Jain 1ac576f2b3
Handle panic on move within empty picker (#1786)
When the picker results output is empty, movement actions result in a panic:
```
thread 'main' panicked at 'attempt to calculate the remainder with a divisor of zero', helix-term/src/ui/picker.rs:420:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

This could be a no-op instead when the matches length is zero.
2022-03-14 11:46:23 +09:00
Blaž Hrastnik 78fba8683b
Picker performance improvements 2022-03-03 16:52:41 +09:00
Ludwig Stecher 59c691d2db
Highlight matching text in file picker suggestions (#1635)
* Highlight matching text in file picker suggestions

* Remove cache, specialize highlighting code

* Fix outdated comments
2022-03-01 10:30:02 +09:00
Bram 40eb1268c7
Close some popups automatically (#1285)
* Add Event::Used to use event callback without consuming

* Close popup if contents ignored event

* collect event results before executing callbacks

* don't add new result variant, use Ignored(..) instead

* break in match cases

* Make auto_close configurable

* fix merge

* auto close hover popups

* fix formatting
2022-02-23 12:46:12 +09:00
Blaž Hrastnik c06155ace4 Extract a helper function for lsp::Location 2022-02-18 14:37:59 +09:00
Blaž Hrastnik af21e2a5b4 Pass through Editor instead of Context 2022-02-17 14:02:42 +09:00
Cole Helbling 6118486eb2 helix-term: implement buffer completer
In order to implement this completer, the completion function needs to
be able to access the compositor's context (to allow it to get the
list of buffers currently open in the context's editor).
2022-02-17 14:02:42 +09:00
Ludwig Stecher 4429993842
Add `PageUp`, `PageDown`, `Ctrl-u`, `Ctrl-d`, `Home`, `End` keyboard shortcuts to file picker (#1612)
* Add `PageUp`, `PageDown`, `Ctrl-u`, `Ctrl-d`, `Home`, `End` keyboard shortcuts to file picker

* Refactor file picker paging logic

* change key mapping

* Add overlay component

* Use closure instead of margin to calculate size

* Don't wrap file picker in `Overlay` automatically
2022-02-15 10:24:03 +09:00
Blaž Hrastnik bd549d8a20 Merge remote-tracking branch 'origin/master' into debug 2022-02-13 18:31:51 +09:00
Blaž Hrastnik f7f55143a1 Improve code action picker by displaying it inline 2022-01-31 16:04:58 +09:00
Benjamin 4044c70eb2
Fix picker won't scroll down when it hits the bottom #1544 (#1567) 2022-01-23 23:06:28 +09:00
Blaž Hrastnik 53d881f172 Store theme scopes on the loader, this way theme isn't passed around 2022-01-23 16:00:24 +09:00
Blaž Hrastnik 6728e44490 syntax: Split parsing and highlighting 2022-01-23 16:00:24 +09:00
Mathis Brossier f5b0821860
Fix panics when resizing (#1408)
* Change buffer.get & buffer.get_mut to return Option, Implement Trait Index & IndexMut to panic

* Prevent FilePicker from drawing outside buffer (rust panics)

* apply suggestion

* add function in_bounds to avoid useless calculations

Co-authored-by: mathis <mathis.brossier@universite-paris-saclay.fr>
2022-01-16 10:55:28 +09:00
Omnikar e91d357fae
Macros (#1234)
* Macros WIP

`helix_term::compositor::Callback` changed to take a `&mut Context` as
a parameter for use by `play_macro`

* Default to `@` register for macros

* Import `KeyEvent`

* Special-case shift-tab -> backtab in `KeyEvent` conversion

* Move key recording to the compositor

* Add comment

* Add persistent display of macro recording status

When macro recording is active, the pending keys display will be shifted
3 characters left, and the register being recorded to will be displayed
between brackets — e.g., `[@]` — right of the pending keys display.

* Fix/add documentation
2021-12-12 21:16:48 +09:00
Blaž Hrastnik cab09093dd fix: Normalize backtab into shift-tab
Fixes #1150
2021-12-06 12:25:19 +09:00
Blaž Hrastnik 34f46e7502 Bump rust to 1.57, fix new lint failures 2021-12-03 12:48:07 +09:00
Blaž Hrastnik 0eadeab8c7 dap: Remove the prompt line parameter, use insert_str instead 2021-11-22 11:14:10 +09:00
Blaž Hrastnik d1854d8e6a Merge remote-tracking branch 'origin/master' into debug 2021-11-21 20:06:45 +09:00
Ebbe Steenhoudt edc976b6bb
Added workspace_symbol_picker (#1041)
* Added workspace_symbol_picker

* Moved truncation of the symbol pickers to the end.

* Fixed typo
2021-11-15 00:12:56 +09:00
Blaž Hrastnik d3def16584 fix: shift-tab mappings broken after efc2b4c7 2021-11-12 16:21:03 +09:00
Gokul Soumya efc2b4c77b
Refactor keyevent handling using key, ctrl macros (#1058)
Adds ctrl! and alt! macros (which existed before the big keymap
refactor) and uses them in event handling of Components. Note
that this converts crossterm's KeyEvent to our own KeyEvent on
each invocation of handle_event in Components.
2021-11-11 00:58:46 +09:00
Blaž Hrastnik 3b8d5102ac Make picker take the whole context, not just editor 2021-11-07 18:03:04 +09:00
Blaž Hrastnik f2b709a3c3 Merge branch 'master' into debug 2021-11-07 00:28:19 +09:00
diegodox 70d21a903f
Prevent preview binary or large file (#939)
* Prevent preview binary or large file (#847)

* fix wrong method name

* fix add use trait

* update lock file

* rename MAX_PREVIEW_SIZE from MAX_BYTE_PREVIEW

* read small bytes to determine cotent type

* [WIP] add preview struct to represent calcurated preveiw

* Refactor content type detection

- Remove unwraps
- Reuse a single read buffer to avoid 1kb reallocations between previews

* Refactor preview rendering so we don't construct docs when not necessary

* Replace unwarap whit Preview::NotFound

* Use index access to hide unwrap

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

* fix Get and unwarp equivalent to referce of Index acess

* better preview implementation

* Rename Preview enum and vairant

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>

* fixup! Rename Preview enum and vairant

* simplify long match

* Center text, add docs, fix formatting, refactor

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
2021-11-04 12:24:52 +09:00
Omnikar 5b5d1b9dff
Truncate the starts of file paths instead of the ends in picker (#951)
* Truncate the starts of file paths in picker

* Simplify the truncate implementation

* Break loop at appropriate point

* Fix alignment and ellipsis presence

* Remove extraneous usage of `x_offset`

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2021-11-04 12:24:05 +09:00
Oskar Nehlin 0f886af4b9
Add commands for moving between splits with a direction (#860)
* Add commands for moving between splits with a direction

* Update keymaps

* Change picker mapping

* Add test and clean up some comments
2021-10-23 20:06:40 +09:00
Blaž Hrastnik 182a59b552 Update to rust 1.56 + 2021 edition 2021-10-22 12:15:18 +09:00
VuiMuich 67829976fa
Add `C-j` and `C-k` to keybinds for picker (#876)
* Add `C-j` and `C-k` for moving down/up in pickers

* Add new binds to keymap doc
2021-10-19 18:37:38 +09:00
Blaž Hrastnik 0a6b60085a Merge branch 'master' into debug 2021-10-17 13:51:56 +09:00
Leoi Hung Kin a6852fb88f
Picker: Don't panick at move_up/move_down when matches is empty (#818) 2021-10-09 20:34:10 +09:00
Dmitry Sharshakov bf53aff27d Merge branch 'master' into debug 2021-09-25 23:14:59 +03:00
Blaž Hrastnik c7d6e4461f fix: Wrap around the top of the picker menu when scrolling
Forgot to port the improvements in menu.rs

Fixes #734
2021-09-17 14:43:06 +09:00
Blaž Hrastnik 2ce87968cd ui: Be smarter about centering previews
Try centering the whole block. If the block is too big for the viewport,
then make sure that the first line is within the preview.
2021-09-08 14:19:25 +09:00
Dmitry Sharshakov 2d35b7b99c
Normalize line in picker preview to avoid crash 2021-09-05 14:31:16 +03:00
Dmitry Sharshakov 1befbd076c Add command for editing breakpoint condition 2021-09-04 22:57:58 +03:00
Blaž Hrastnik a3bd80a6fa ui: prompt: Avoid allocating a prompt name if it's a static string 2021-08-31 18:29:24 +09:00
Kirawi b99db7c687
Move path util functions from helix-term to helix-core (#650) 2021-08-25 10:04:05 +09:00
Blaž Hrastnik bf5b9a9f35 ui: Tone down the preview highlight by adding a new scope 2021-08-24 13:25:39 +09:00
Blaž Hrastnik e6cb183134 ui: Fix preview window padding: we want horizontal, not vertical 2021-08-24 13:25:39 +09:00
Blaž Hrastnik a5c3c6c6a9 ui: Highlight line ranges in the preview 2021-08-24 13:25:39 +09:00
Gokul Soumya f9375f449c
Refactor new Rect construction (#575)
* Refactor new Rect construction

Introduces methods that can be chained to construct new Rects
out of pre-existing ones

* Clamp x and y to edges in Rect chop methods

* Rename Rect clipping functions
2021-08-21 14:21:20 +09:00
Kirawi da8810809a use `ui.text.focus` for the picker (fix #622) 2021-08-20 10:43:08 +09:00
Blaž Hrastnik 4167201344 ui: picker: Position count according to input bar 2021-08-13 18:00:04 +09:00
Blaž Hrastnik eb9ac0a743 ui: picker: Use ui.selection instead of ui.selection.primary 2021-08-13 17:59:47 +09:00
Blaž Hrastnik f20dc1283d ui: picker: Render matches/total counts 2021-08-13 17:56:37 +09:00
Gokul Soumya d84f8b5fde
Show file preview in split pane in fuzzy finder (#534)
* Add preview pane for fuzzy finder

* Fix picker preview lag by caching

* Add picker preview for document symbols

* Cache picker preview per document instead of view

* Use line instead of range for preview doc

* Add picker preview for buffer picker

* Fix render bug and refactor picker

* Refactor picker preview rendering

* Split picker and preview and compose

The current selected item is cloned on every event, which is
undesirable

* Refactor out clones in previewed picker

* Retrieve doc from editor if possible in filepicker

* Disable syntax highlight for picker preview

Files already loaded in memory have syntax highlighting enabled

* Ignore directory symlinks in file picker

* Cleanup unnecessary pubs and derives

* Remove unnecessary highlight from file picker

* Reorganize buffer rendering

* Use normal picker for code actions

* Remove unnecessary generics and trait impls

* Remove prepare_for_render and make render mutable

* Skip picker preview if screen small, less padding
2021-08-12 16:00:42 +09:00
Blaž Hrastnik 63e54e30a7 Implement in-memory prompt history
Implementation is similar to kakoune: we store the entries into
a register.
2021-07-26 11:19:33 +09:00
Ivan Tham eba0bbda2e Resume last picker
Inspired by space ' in doom emacs.
2021-07-22 11:22:27 +09:00
Nathan Vegdahl efa3389b6a Fix unused variable, parameter, and `mut` warnings in helix-term. 2021-07-01 19:06:52 -07:00
Keith Simmons 4418e17547
reverse the dependency between helix-tui and helix-view (#366)
* reverse the dependency between helix-tui and helix-view by moving a fiew types to view

* fix tests

* clippy and format fixes

Co-authored-by: Keith Simmons <keithsim@microsoft.com>
2021-06-25 12:58:15 +09:00
Gokul Soumya 18beda38ac Add … when chars are truncated in picker 2021-06-25 09:28:24 +09:00
Gokul Soumya fb8e7dc25b Fix picker item width overflow
Fixes #352
2021-06-24 12:00:08 +09:00
Joe Neeman fd1ae35051 Make the prompt callback take a Context. 2021-06-23 10:03:11 +09:00
Blaž Hrastnik 20f33ead67 minor: Remove old TODOs 2021-06-22 23:26:34 +09:00
Ivan Tham 124514aa70 Add cursor kind to separate hidden cursor from pos
Now IME cursor position should be correct since we can still set cursor
position without drawing the cursor.
2021-06-15 23:46:21 +08:00
Ivan Tham 002f1ad397 Add filter ability to picker
Inspired by doom emacs. Able to filter picker options multiple times.
2021-06-15 12:00:31 +08:00
Ivan Tham 1953588873 Change picker horizontal split to h
Follow window mode and vim behavior, x seemed weird.
2021-06-12 21:17:48 +09:00
Kevin Sjöberg 1bb9977faf Match keybindings of menu 2021-06-09 09:54:22 +09:00
Kevin Sjöberg aa8a8baeeb Calculate offset when moving picker cursor 2021-06-06 19:18:09 +09:00
Kevin Sjöberg 2ac496f919 Do not move past number of matches 2021-06-06 18:04:45 +09:00
Blaž Hrastnik d54ae09d3b ESC should exit both completion and insert mode 2021-05-29 10:37:47 +09:00
Blaž Hrastnik d708efe275 Fix cursor positioning for prompts 2021-05-29 00:06:23 +09:00
Blaž Hrastnik ccdebb99b5 Drop some useless imports. 2021-05-09 18:32:40 +09:00
Blaž Hrastnik ff4c1d05de Replace the Clear widget with buffer.clear/clear_with. 2021-05-09 18:13:50 +09:00
Blaž Hrastnik 1255bcb8a3 Simplify the compositor callback. 2021-05-09 18:02:31 +09:00
Blaž Hrastnik f0712479cb Define text color (mostly) in theme.toml. 2021-05-07 17:42:09 +09:00
Blaž Hrastnik 8b33ba2284 Correct the naming issue with vsplit and hsplit being swapped. 2021-04-08 15:52:04 +09:00