Skip to content

QuickPickOptions.onDidSelectItem hides the PickList when another document is loaded in the view #7019

Closed

Description

  • VSCode Version: 1.1.1
  • OS Version: Windows

Steps to Reproduce:

  1. Defines a onDidSelectItem function that will open and show a text document, like this:
  let options = <vscode.QuickPickOptions>{  
    placeHolder: 'Type a line number or a piece of code to navigate to',
    matchOnDescription: true,
    onDidSelectItem: item => {
      if (item.detail.toString().toLowerCase() == vscode.window.activeTextEditor.document.uri.fsPath.toLowerCase()) {
        revealLine(parseInt(item.label) - 1);
      } else { // here is the problem
        let uriDocument: vscode.Uri = vscode.Uri.file(item.detail.toString());
        vscode.workspace.openTextDocument(uriDocument).then(doc => {
          vscode.window.showTextDocument(doc).then(editor => {
             // any code can be added here
             //revealLine(parseInt(item.label) - 1);
          });
        });
      }
    }
  };
  1. Shows a vscode.window.showQuickPick, with that vscode.QuickPickOptions, like this:
  vscode.window.showQuickPick(items, options).then(selection => {
    // do anything
  });

Whenever the else code block in onDidSelectItem function is reached (wich will load another document) the PickList disappears. (no matter the code added inside showTextDocument, even nothing).

I don't know if this is the expected behavior or not, but it would good that the PickList remains visible. With that, I could have a preview of other documents.

Thanks in advance

Activity

  1. added
    bug
    on May 30, 2016
  2. jrieken commented on May 30, 2016

    @jrieken
    Contributor

    Today, quick pick closes on focus lost. We should add an option to prevent that.

  3. jrieken commented on May 30, 2016

    @jrieken
    Contributor

    Benjamin Pasero (@bpasero) Andre Weinand (@weinand) This might also be useful for the process picker work

  4. weinand commented on May 30, 2016

    @weinand
    Contributor

    Johannes Rieken (@jrieken) Then this only needs to be surfaced in vscode.d.ts.

  5. jrieken commented on May 30, 2016

    @jrieken
    Contributor

    Alessandro Fragnani (@alefragnani) Can you try this with the preserveFocus when calling showTextDocument? It should not move focus away from the quick pick widget so that it stays open.

  6. alefragnani commented on May 30, 2016

    @alefragnani
    Author

    Johannes Rieken (@jrieken) It works perfectly, thanks 👍

    By the way, Is there an API to show items in the pick list, just like the Go to Symbol, where you have some kind of groups of items (that appears when you type '@:' in the pick list)?

    vscode-pick-list-like-go-to-symbol

    Currently, I'm using the QuickPickItem.detail property to show the file name of the item in the pick list, but the Go to Symbol grouping approach is much better, because it does not repeat that info for every item in the pick list.

    Thanks in advance

  7. bpasero commented on May 30, 2016

    @bpasero
    Contributor

    This is something we do support from within code but not exposed as API. The related option for a picker entry is in https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/services/quickopen/common/quickOpenService.ts#L18

    We use it e.g. if you click on the whitespace picker in the status bar.

  8. alefragnani commented on May 30, 2016

    @alefragnani
    Author

    Benjamin Pasero (@bpasero), That´s exactly what I mean. Any chances in exposing this API?

  9. jrieken commented on May 31, 2016

    @jrieken
    Contributor

    Unsure - I don't like that fact the separator/group must be repeated on each item. Tho I also don't like the idea of a complex data structure. For now, I would opt to keep this simple

  10. bpasero commented on May 31, 2016

    @bpasero
    Contributor

    The way it works currently with string array as pick items is easy and would probably not allow for more complex things like groups and separators. For sure I would not just copy the internal API we have and make it public.

  11. alefragnani commented on May 31, 2016

    @alefragnani
    Author

    I didn't mean to expose that API, but only use the separator attribute idea. Sorry about the misundertandig.

    I didn't look at the source to see how that API is related to the published API, so I don't know hard would be to publish a separator/grouping attribute and use it as in Benjamin Pasero (@bpasero) example (whiltespace picker). But since the same idea appears in other pickers too, like Go to Symbol, Open Recent, it's something that I was expecting to be able to use. Specially because it keeps the UI cleaner.

    Johannes Rieken (@jrieken) I totally agree about keep this simple 👍

    Thanks

  12. 3 remaining items

  13. jrieken commented on Jun 28, 2016

    @jrieken
    Contributor

    Backlog or No milestone is the same to me

  14. alefragnani commented on Jun 28, 2016

    @alefragnani
    Author

    Ah, ok.. Thanks 👍

  15. jrieken commented on Aug 25, 2016

    @jrieken
    Contributor

    We did add ignoreFocusOut flags for quick pick and input

  16. bpasero commented on Sep 2, 2016

    @bpasero
    Contributor

    Marking as verification-found due to #11442

  17. removed
    bug
    on Sep 2, 2016
  18. bpasero commented on Sep 2, 2016

    @bpasero
    Contributor

    untitled

    Alessandro Fragnani (@alefragnani) if you preserveFocus when opening an editor you can get this to work already today without the new ignoreFocusOut option

  19. added
    bug
    verified
    on Sep 2, 2016
  20. alefragnani commented on Sep 2, 2016

    @alefragnani
    Author

    Benjamin Pasero (@bpasero) yes, I'm already using it as Johannes Rieken (@jrieken) suggested in May 👍

    I think the issue remained open not based in the original post (about preserve focus) but because of expose grouping API. It lost the June tag/milestone and only last week new comments were added.

    Would be valid to re-open (add a new issue) for that grouping feature in Pick List?

  21. jrieken commented on Sep 2, 2016

    @jrieken
    Contributor

    Let's track the grouping in a new item.

  22. 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

apibugverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions