Skip to content

How to handle focused items in vscode.window.showQuickPick? #540

Closed

Description

From Alessandro Fragnani (@alefragnani) on November 18, 2015 1:38

I would like to replicate the behavior of Go to Symbol command, where I give a list if items and the user can use UP/DOWN keys to navigate between them. Each now focused item, it scrolls the editor to the position where that piece of code is located. My intention is to use the line number to navigate.

I was thinking to use vscode.window.showQuickPick, but didn' find how to do this (no event, for instance).

Thanks in advance.

Copied from original issue: Microsoft/vscode-extensionbuilders#122

Activity

  1. jrieken commented on Nov 24, 2015

    @jrieken
    ContributorAuthor

    From Sean McBreen (@seanmcbreen) on November 18, 2015 4:49

    I'm not aware of a way to do that [navigate as a user highlights but does not select] in QuickPick - we obviously event for theme previews so it's possible. Adding Benjamin Pasero (@bpasero) but I think this is something for us to look at adding vs something we have.

  2. jrieken commented on Nov 24, 2015

    @jrieken
    ContributorAuthor

    From Benjamin Pasero (@bpasero) on November 18, 2015 8:26

    Alessandro Fragnani (@alefragnani) you will need to implement registerDocumentSymbolProvider !

  3. jrieken commented on Nov 24, 2015

    @jrieken
    ContributorAuthor

    From Alessandro Fragnani (@alefragnani) on November 21, 2015 3:23

    Benjamin Pasero (@bpasero) how do I do it without interfere in the original DocumentSymbolProvider already associated to each document?

    I could implement a registerDocumentSymbolProvider and fill the SymbolInformation array with my items. But only when I call Go to Symbol command, my items appeared. And so, for files like .ts, .json, which already have their symbols, it merged. In the screenshot below, the first 3 items are mine, the other 3 are symbols automatically generated for this .json file

    vscode-gotosymbol

    If I could cancel the other symbols, it could help, but I guess this is not the way. At least, it doesn't appears correct to use the Go to Symbol command.

    Thanks for your help

  4. jrieken commented on Nov 24, 2015

    @jrieken
    ContributorAuthor

    From Benjamin Pasero (@bpasero) on November 21, 2015 7:29

    Johannes Rieken (@jrieken) is the one to answer

  5. jrieken commented on Nov 24, 2015

    @jrieken
    ContributorAuthor

    The result of document symbol providers are always merged because the document symbol feature is there provide a full outline of all symbols in a document.

    Alessandro Fragnani (@alefragnani) It seems we don't have the right API for you. What is your exact use-case and what do you want to do with apis (DocumentSymbol and quick pick)?

  6. jrieken commented on Nov 24, 2015

    @jrieken
    ContributorAuthor

    From Alessandro Fragnani (@alefragnani) on November 24, 2015 9:46

    Johannes Rieken (@jrieken) I would like to add an enhancement to my Bookmarks extension, listing the lines where the bookmarks are, with a preview of the line, and when the user hits UP/DOWN for each item, the editor would scroll to that line. In the screenshot above, the first 3 items that are the bookmarks (line number and preview).

    This detect user focusing items when moving up/down behavior is the reason why I asked to replicate Go To Symbol command 😄

  7. jrieken commented on Nov 24, 2015

    @jrieken
    ContributorAuthor

    Alessandro Fragnani (@alefragnani) Thanks for clarifying. The document symbol provider doesn't seem like the right vehicle for this, despite its auto-revel behaviour. Being pinged on focus is a valid request. I will give it some though...

  8. added
    feature-request
    on Nov 24, 2015
  9. jrieken commented on Dec 23, 2015

    @jrieken
    ContributorAuthor

    Could be as simple as having a function in the QuickPickOptions, like so

    const options:vscode.QuickPickOptions = {
      placeholder: 'Pick something',
      onDidFocusItem: item => { console.log(item); }
    }
  10. jrieken commented on Jan 5, 2016

    @jrieken
    ContributorAuthor

    this will be handled by #1795

  11. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apifeature-request

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions