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

Test: Proposed API for QuickPickItem separators #137745

Closed
2 tasks done
TylerLeonhardt opened this issue Nov 23, 2021 · 1 comment
Closed
2 tasks done

Test: Proposed API for QuickPickItem separators #137745

TylerLeonhardt opened this issue Nov 23, 2021 · 1 comment

Comments

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Nov 23, 2021

Refs: #74967

Complexity: 4

Create Issue


In this milestone, we've introduced the highly anticipated QuickPick Separators into the API.

API definition:

// https://github.com/microsoft/vscode/issues/74967
export enum QuickPickItemKind {
Default = 1,
Separator = 2,
}
export interface QuickPickItem {
kind?: QuickPickItemKind
}
}

When you set the kind to Separator on a QuickPickItem, that QPI will be treated like a separator. Here's an example:

	const result = await window.showQuickPick([
		{
			label: 'APIs',
			kind: QuickPickItemKind.Separator
		},
		{
			label: 'showQuickPick',
		},
		{
			label: 'showInputBox',
		},
		{
			label: 'createQuickPick',
		},
		{
			label: 'createInputBox',
		},
		{
			label: 'Types',
			kind: QuickPickItemKind.Separator
		},
		{
			label: 'QuickPickItemKind',
		},
		{
			label: 'QuickInputButton',
		},
		{
			label: 'QuickQuick',
		},
		{
			label: 'InputBox',
		},
	]);

	window.showInformationMessage(`You selected: ${result?.label ?? 'nothing'}`);

or the long form:

	const qp = window.createQuickPick();
	qp.items = sameItemsAsAbove;

	qp.onDidAccept(() => {
		qp.dispose();
		window.showInformationMessage(`You selected: ${qp.selectedItems[0]?.label ?? 'nothing'}`);
	});

	qp.show();

gets you:
image

Things to test

  • Play around with setting the kind property
  • Keep in mind that the only property that matters when setting kind to Separator is label all others will be ignored (test this)
  • Ensure you can set label to empty string to add a blank separator
  • in the long form, ensure you are also able to add buttons to the QPI and they are rendered properly (they'll be ignored if you add them to the separator QPIs) NOTE: You will need the latest vscode.d.ts to test buttons as they are being finalized so run npx vscode-dts main

Useful stuff

	"enabledApiProposals": [
		"quickPickSeparators"
	],

Note the name of the proposed API is gathered from the file name in the vscode-dts folder

@TylerLeonhardt TylerLeonhardt added this to the November 2021 milestone Nov 23, 2021
@TylerLeonhardt TylerLeonhardt changed the title Test: Proposed API for QuickPick separators Test: Proposed API for QuickPickItem separators Nov 23, 2021
@ghost ghost assigned kimadeline and weinand Nov 30, 2021
@weinand weinand removed their assignment Nov 30, 2021
@weinand
Copy link
Contributor

weinand commented Nov 30, 2021

Works great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants