Commit Graph

45 Commits (6a3f7f2c399f0b92cef97b0c85ebe976fd7cfcac)

Author SHA1 Message Date
Michael Davis 39f7ba36e0
ignore Enter keypress when menu has no selection (#1704)
* ignore Enter keypress when menu has no selection

supersedes #1622

Builds on the work in #1285. I want to allow Enter to create a newline
when there is no selection in the autocomplete menu.

This occurs somewhat often when using LSP autocomplete in Elixir which
uses `do/end` blocks (and I set the autocomplete menu delay to 0 which
exacerbates the problem):

```elixir
defmodule MyModule do
  def do_foo(x) do
    x
  end
  def other_function(y) do|
end
```

Here the cursor is `|` in insert mode. The LSP suggests `do_foo` but I
want to create a newline. Hitting Enter currently closes the menu,
so I end up having to hit Enter twice when the module contains any
local with a `do` prefix, which can be inconsistent. With this change,
we ignore the Enter keypress to end up creating the newline in this case.

* pop compositor layer when ignoring Enter keypress

* move closing function out of consumed event result closure

* explicitly label close_fn as an 'Option<Callback>'
2 years ago
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
2 years ago
Blaž Hrastnik 36b975c4ce ui: menu: Don't allocate scrollbar space if options fit 2 years ago
Blaž Hrastnik f10a06f4de ui: Only render menu scrollbar if it doesn't fit 2 years ago
Blaž Hrastnik 094a0aa3f9 Render code actions as a menu, allow adding padding to popup 2 years ago
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>
2 years ago
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
3 years ago
Blaž Hrastnik cab09093dd fix: Normalize backtab into shift-tab
Fixes #1150
3 years ago
Blaž Hrastnik d3def16584 fix: shift-tab mappings broken after efc2b4c7 3 years ago
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.
3 years ago
CossonLeo b142fd4080
move_up will select last item, when no item selected (#907) 3 years ago
CossonLeo bca98b5bed
Add c-j c-k to menu keymap for move_up move_down (#908) 3 years ago
Blaž Hrastnik 182a59b552 Update to rust 1.56 + 2021 edition 3 years ago
Blaž Hrastnik 2c0468ffd1 fix: If backspacing past the start offset, cancel completion
Refs #822
3 years ago
Blaž Hrastnik 32977ed341 ui: Trigger recalculate_size per popup render so contents can readjust 3 years ago
CossonLeo d6a9c2c0f6
Add ui.menu text style (#664)
* add menu text style

* add ui.menu.text ui.info ui.info.text to book

* change ui.menu.text to ui.menu

* fix book's ui.menu
3 years ago
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
3 years ago
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
3 years ago
Blaž Hrastnik f917b5a441 ui: completion: Use sort_text to sort the completions 3 years ago
Blaž Hrastnik b20a5c4c0e ui: menu: Allow wrapping around on ctrl-p/shift tab 3 years ago
Blaž Hrastnik 1789dfabfe fix: ui/menu: Don't allow scrolling past the end of completion
Fixes #472
3 years ago
Blaž Hrastnik 58d08d36ae Simplify ui/menu.rs 3 years ago
Blaž Hrastnik 5292fe0f7d Calculate completion popup sizing
Fixes #220
3 years ago
Nathan Vegdahl efa3389b6a Fix unused variable, parameter, and `mut` warnings in helix-term. 3 years ago
Nathan Vegdahl 702a0491db Remove #[allow(unused)] from helix-term, and fix unused imports.
Lots of other warning still left.  Will address in subsequent commits.
3 years ago
Blaž Hrastnik cad14c6b46 Address nightly clippy warnings 3 years ago
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>
3 years ago
Kevin Sjöberg 29962a5bd9 Fix Shift-Tab for moving upwards in menu 3 years ago
Blaž Hrastnik 3336023614 ui: Menu rendering adjustments 3 years ago
Blaž Hrastnik b114cfa119 Display more data in completion popups. 3 years ago
Blaž Hrastnik ccdebb99b5 Drop some useless imports. 3 years ago
Blaž Hrastnik 1255bcb8a3 Simplify the compositor callback. 3 years ago
Blaž Hrastnik f0712479cb Define text color (mostly) in theme.toml. 3 years ago
Blaž Hrastnik fd4fd12fa3 clippy lint 3 years ago
Blaž Hrastnik 95d0bba81a ui: Improve completion state handling. 3 years ago
Blaž Hrastnik ceea5eacd8 clippy lint 3 years ago
Blaž Hrastnik a24c3fff54 Filter the completion menu based on text entered. 3 years ago
Blaž Hrastnik 350081a3af Fix crash if pressing enter when nothing selected in completion. 3 years ago
Blaž Hrastnik cbcacb1063 Merge some imports. 3 years ago
Blaž Hrastnik b7dd7310c4 syntax: Reuse parser instances. highlight_iter() no longer needs &mut. 3 years ago
Blaž Hrastnik ddcf5156c0 ui: menu: Adjust scroll via required_size area caching. 3 years ago
Blaž Hrastnik 5ea610c41d ui: Move terminal into compositor, redo required_size hints. 3 years ago
Blaž Hrastnik a21d96e729 ui: Scrollable popup menu, with scrollbar indicator. 3 years ago
Blaž Hrastnik 0b85c16be9 ui: Share popup code with menu.
Menu is now just wrapped in a popup.
3 years ago
Blaž Hrastnik d4b85ce18d popup: wip work on completion popups 3 years ago