Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickers "v2" #9647

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Pickers "v2" #9647

wants to merge 20 commits into from

Commits on Apr 24, 2024

  1. Use an AsyncHook for picker preview highlighting

    The picker previously used the IdleTimeout event as a trigger for
    syntax-highlighting the currently selected document in the preview pane.
    This is a bit ad-hoc now that the event system has landed and we can
    refactor towards an AsyncHook (like those used for LSP completion and
    signature-help). This should resolve some odd scenarios where the
    preview did not highlight because of a race between the idle timeout
    and items appearing in the picker.
    the-mikedavis committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    b0828d2 View commit details
    Browse the repository at this point in the history
  2. Refactor Picker in terms of columns

    `menu::Item` is replaced with column configurations for each picker
    which control how a column is displayed and whether it is passed to
    nucleo for filtering. (This is used for dynamic pickers so that we can
    filter those items with the dynamic picker callback rather than nucleo.)
    
    The picker has a new lucene-like syntax that can be used to filter the
    picker only on certain criteria. If a filter is not specified, the text
    in the prompt applies to the picker's configured "primary" column.
    
    Adding column configurations for each picker is left for the child
    commit.
    the-mikedavis committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    e90a3f9 View commit details
    Browse the repository at this point in the history
  3. Add a special query syntax for Pickers to select columns

    Now that the picker is defined as a table, we need a way to provide
    input for each field in the picker. We introduce a small query syntax
    that supports multiple columns without being too verbose. Fields are
    specified as `%field pattern`. The default column for a picker doesn't
    need the `%field` prefix. The field name may be selected by a prefix
    of the field, for example `%p foo.rs` rather than `%path foo.rs`.
    
    Co-authored-by: ItsEthra <107059409+ItsEthra@users.noreply.github.com>
    the-mikedavis and ItsEthra committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    0e38f12 View commit details
    Browse the repository at this point in the history
  4. Add column configurations for existing pickers

    This removes the menu::Item implementations for picker item types and
    adds `Vec<Column<T, D>>` configurations.
    the-mikedavis committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    a6b74f2 View commit details
    Browse the repository at this point in the history
  5. Replace picker shutdown bool with version number

    This works nicely for dynamic pickers: we stop any running jobs like
    global search that are pushing to the injector by incrementing the
    version number when we start a new request. The boolean only allowed
    us to shut the picker down once, but with a usize a picker can have
    multiple "sessions" / "life-cycles" where it receives new options
    from an injector.
    the-mikedavis committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    15b8bb1 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0be5b70 View commit details
    Browse the repository at this point in the history
  7. Bump nucleo to v0.4.1

    We will use this in the child commit to improve the picker's running
    indicator. Nucleo 0.4.0 includes an `active_injectors` member that we
    can use to detect if anything can push to the picker. When that count
    drops to zero we can remove the running indicator.
    
    Nucleo 0.4.1 contains a fix for crashes with interactive global search
    on a large directory.
    the-mikedavis committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    96d7e9c View commit details
    Browse the repository at this point in the history
  8. Consolidate DynamicPicker into Picker

    DynamicPicker is a thin wrapper over Picker that holds some additional
    state, similar to the old FilePicker type. Like with FilePicker, we want
    to fold the two types together, having Picker optionally hold that
    extra state.
    
    The DynamicPicker is a little more complicated than FilePicker was
    though - it holds a query callback and current query string in state and
    provides some debounce for queries using the IdleTimeout event.
    We can move all of that state and debounce logic into an AsyncHook
    implementation, introduced here as `DynamicQueryHandler`. The hook
    receives updates to the primary query and debounces those events so
    that once a query has been idle for a short time (275ms) we re-run
    the query.
    
    A standard Picker created through `new` for example can be promoted into
    a Dynamic picker by chaining the new `with_dynamic_query` function, very
    similar to FilePicker's replacement `with_preview`.
    
    The workspace symbol picker has been migrated to the new way of writing
    dynamic pickers as an example. The child commit will promote global
    search into a dynamic Picker as well.
    the-mikedavis committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    a80486a View commit details
    Browse the repository at this point in the history
  9. Remove sym_picker helper fun

    The parent commit split out the workspace symbol picker to an inline
    definition so the `workspace` parameter is never passed as `true`. We
    should consolidate this picker definition into the symbol_picker
    function.
    the-mikedavis committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    bb89be8 View commit details
    Browse the repository at this point in the history

Commits on Apr 29, 2024

  1. Configuration menu
    Copy the full SHA
    61c3a14 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b854b5e View commit details
    Browse the repository at this point in the history
  3. Add a hidden column for the global search line contents

    We could expand on this in the future to have different preview modes
    that you can toggle between with C-t. Currently that binding just hides
    the preview but it could switch between different preview modes and in
    one mode hide the path and just show the line contents.
    the-mikedavis committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    d751376 View commit details
    Browse the repository at this point in the history
  4. Request a UI redraw on Drop of an Injector

    This fixes the changed files picker when used against a clean worktree
    for example. Without it the running indicator does not disappear. It
    also simplifies the dynamic query handler's implementation so that it
    doesn't need to request a redraw explicitly.
    
    Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
    the-mikedavis and pascalkuthe committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    f238f28 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    a1a9685 View commit details
    Browse the repository at this point in the history
  6. Convert LSP URIs into custom URIs

    This introduces a custom URI type in core meant to be extended later
    if we want to support other schemes. For now it's just a wrapper over a
    PathBuf. We use this new URI type to firewall `lsp::Url`. This was
    previously done in 8141a4a but using a custom URI type is more flexible
    and will improve the way Pickers handle paths for previews in the child
    commit(s).
    
    Co-authored-by: soqb <cb.setho@gmail.com>
    the-mikedavis and soqb committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    fe1e4fa View commit details
    Browse the repository at this point in the history
  7. Avoid allocations in Picker file preview callback

    The `FileLocation` and `PathOrId` types can borrow paths rather than
    requiring them to be owned. This takes a refactor of the preview
    functions and preview internals within `Picker`. With this change we
    avoid an unnecessary `PathBuf` clone per render for any picker with a
    file preview function (i.e. most pickers).
    
    This refactor is not fully complete. The `PathOrId` is _sometimes_ an
    owned `PathBuf`. This is for pragmatic reasons rather than technical
    ones. We need a further refactor to introduce more core types like
    `Location` in order to eliminate the Cow and only use `&Path`s within
    `PathOrId`. This is left for future work as it will be a larger refactor
    almost entirely fitting into the LSP commands module and helix-core -
    i.e. mostly unrelated to refactoring the `Picker` code itself.
    
    Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
    the-mikedavis and pascalkuthe committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    77a290e View commit details
    Browse the repository at this point in the history
  8. Accept 'IntoIterator<Item = T>' for Picker::new options

    `Picker::new` loops through the input options to inject each of them, so
    there's no need to collect into an intermediary Vec. This removes some
    unnecessary collections. Also, pickers that start with no initial
    options can now pass an empty slice instead of an empty Vec.
    
    Co-authored-by: Luis Useche <useche@gmail.com>
    the-mikedavis and useche committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    c027580 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    b051a72 View commit details
    Browse the repository at this point in the history
  10. Accept 'IntoIterator<Item = Column<T, D>>' for picker columns

    This allows us to replace any `vec![..]`s of columns where all columns
    are static with static slices `[..]`.
    the-mikedavis committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    faa6388 View commit details
    Browse the repository at this point in the history
  11. Picker: Highlight the currently active column

    We can track the ranges in the input text that correspond to each column
    and use this information during rendering to apply a new theme key that
    makes the "active column" stand out. This makes it easier to tell at
    a glance which column you're entering.
    the-mikedavis committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    e298b3c View commit details
    Browse the repository at this point in the history