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

vscode: support keepScrollPosition for QuickPick #11002

Merged
merged 1 commit into from
Apr 8, 2022

Conversation

vince-fugnitto
Copy link
Member

@vince-fugnitto vince-fugnitto commented Apr 7, 2022

What it does

The pull-request adds support for keepScrollPosition when creating a QuickPick. The option is used to enforce that the menu does not scroll back to the top of the list when there is an update to the items in the list.

The updates should also help with our VS Code compatibility report.

Extension Videos

master:

master-quick-pick.mov

pull-request:

pr-quick-pick.mov

How to test

The following extension (vscode-keep-scroll-position-0.0.1.vsix.zip) can be used to test the option when creating a quick-pick, the extension creates a quick-pick with keepScrollPosition set to true, and after some time it will update the list.

On master this would cause the list to jump to the top after the update.

Extension Code
let disposable = vscode.commands.registerCommand('vscode-keep-scroll-position.show', async () => {

    // Create the quick pick.
    const pick = vscode.window.createQuickPick();

    // Set options for the quick pick.
    const initialItems = [...Array(50).keys()].map(i => <vscode.QuickPickItem>{ label: `Initial Item ${i.toFixed()}` });
    pick.items = initialItems;
    pick.keepScrollPosition = true;

    // Display the quick pick.
    pick.show();

    // Wait some time.
    await new Promise(resolve => setTimeout(resolve, 5000));

    // Update the items to test the update.
    const updatedItems = [...Array(20).keys()].map(i => <vscode.QuickPickItem>{ label: `Updated Item: ${i.toFixed()}` });
    pick.items = [...initialItems, ...updatedItems];
});
  1. include vscode-keep-scroll-position-0.0.1.vsix.zip
  2. start the application
  3. trigger the command Quick Pick: Show
  4. scroll the quick pick menu to the end
  5. confirm that after a few seconds the position is kept
  6. scroll to the bottom - confirm the updated items exist

Review checklist

Reminder for reviewers

Signed-off-by: vince-fugnitto [email protected]

The commit adds support for `keepScrollPosition` when creating a
`QuickPick`. The option is available from the VS Code API and should
help with our compatibility.

Signed-off-by: vince-fugnitto <[email protected]>
@vince-fugnitto vince-fugnitto added monaco issues related to monaco vscode issues related to VSCode compatibility labels Apr 7, 2022
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I can confirm that the quick input dropdown moves to the start on master and keeps the current position with the changes 👍

@vince-fugnitto vince-fugnitto merged commit b8fd666 into master Apr 8, 2022
@vince-fugnitto vince-fugnitto deleted the vf/keepScrollPosition branch April 8, 2022 13:32
@github-actions github-actions bot added this to the 1.25.0 milestone Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
monaco issues related to monaco vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants