in the past DocumentDidChange and SelectionDidChange events were implemented in
a simplistic manner to get a simple prototype out. However, if you want to use
these events in more complex scenarios with interdependencies between the two
handlers the system fell short.
The `SelectionDidChange` event was dispatched before the DocumentDidChange (and
not at all if the selection wasn't manually set) so any handlers that wants to
track selection was not able to map their ranges yet.
The reason for this was actually the way that apply_impl was structured. The
function was slightly refactored to address these problems and enable moving
other range mappings to event handlers.
These changes are ported from
<https://redirect.github.com/helix-editor/helix/pull/9801>. It's a
cleanup of `Document::apply_impl` that uses some early returns to
reduce nesting and some reordering of the steps. The early returns
bail out of `apply_impl` early if the transaction fails to apply or
if the changes are empty (in which case we emit the SelectionDidChange
event). It's a somewhat cosmetic refactor that makes the function easier
to reason about but it also makes it harder to introduce bugs by mapping
positions through empty changesets for example.
Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
* Document use of filter columns in pickers.
Filtering on columns was implemented in #9647.
The only documentation I could find on this feature
was the PR itself, and the video demo used a different syntax.
* Note that column filters are space-separated.
* Note that picker filters can be abbreviated.
* Specify correct picker in docs.
* Clarify picker filter prefix shortenting.
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Move picker docs to their own section.
* Update book/src/pickers.md
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Improve docs on picker registers, keybinds, and syntax.
* Clarify wording around picker queries.
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
---------
Co-authored-by: Ryan Roden-Corrent <ryan@rcorre.net>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* replicate t-monaghan's changes
* remove View.offset in favour of Document.view_data.view_position
* improve access patterns for Document.view_data
* better borrow checker wrangling with doc_mut!()
* reintroduce ensure_cursor_in_view in handle_config_events
since we sorted out the borrow checker issues using partial borrows,
there's nothing stopping us from going back to the simpler implementation
* introduce helper functions on Document .view_offset, set_view_offset
* fix rebase breakage
Pastes are probably the last edit one means to make before the query
should run so it doesn't need to be debounced.
This makes global search much snappier for example when accepting the
history suggestion from the '/' register or pasting a pattern from the
clipboard or a register.
Two changes from the parent commit:
* Save only the `Picker::primary_query` - so you don't save other parts
of the query, for example `%path foo.rs` while in `global_search`.
* Move the saving out of the `if let Some(option) = self.selection()`
block. So when you hit enter you save to history whether you have a
selection or not. If you want to close the picker without saving to
the register you can use C-c or Esc instead.
The Prompt is set up to push the current line to history when hitting
Enter but the Picker doesn't pass the Enter event down to the Prompt
(for good reason: we don't want the Prompt's behavior of changing
completions when we hit a path separator). We should save the Prompt's
line to its configured history register when hitting Enter when there
is a selection in the Picker.
This currently only applies to `global_search`'s Picker since it's the
only Picker to use `Picker::with_history_register`.
These haven't been updated in a little while. The original plan was to
update the version (in `Cargo.toml`) after a release to the next
planned release date but the way we release now is to update the version
as a part of the release process (just before tagging). Typically this
is all taken care of in the CHANGELOG-updating branch along with the
other documentation changes like the appdata file. The workflow now is
basically just to merge the changelog/release branch, pull, tag and push.
This commit brings the text decoration API inline with the
LineAnnotation API (so they are consistent) resulting in a single
streamlined API instead of multiple ADHOK callbacks.
The line annotation as implemented in #5420 had two shortcomings:
* It required the height of virtual text lines to be known ahead time
* It checked for line anchors at every grapheme
The first problem made the API impractical to use in practice because
almost all virtual text needs to be softwrapped. For example inline
diagnostics should be softwrapped to avoid cutting off the diagnostic
message (as no scrolling is possible). While more complex virtual text
like side by side diffs must dynamically calculate the number of empty
lines two align two documents (which requires taking account both
softwrap and virtual text). To address this, the API has been
refactored to use a trait.
The second issue caused some performance overhead and unnecessarily
complicated the `DocumentFormatter`. It was addressed by only calling
the trait mentioned above at line breaks (instead of always). This
allows offers additional flexibility to annotations as it offers
the flexibility to align lines (needed for side by side diffs).