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

Preselect default formatter #73535

Merged
merged 2 commits into from May 11, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -209,11 +209,14 @@ async function showFormatterPick(accessor: ServicesAccessor, model: ITextModel,
};
});

// auto focus the default formatter
let autoFocusItem = picks.filter((pick) => pick.description)[0];
Copy link
Member

Choose a reason for hiding this comment

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

this is not nice/proper as it builds on a side-effect of a default formatter having a description. it would be better to use the loop above and the if check on line 208

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does make sense, thanks for the feedback. I added a new commit.


const configurePick: IQuickPickItem = {
label: nls.localize('config', "Configure Default Formatter...")
};

const pick = await quickPickService.pick([...picks, { type: 'separator' }, configurePick], { placeHolder: nls.localize('format.placeHolder', "Select a formatter") });
const pick = await quickPickService.pick([...picks, { type: 'separator' }, configurePick], { placeHolder: nls.localize('format.placeHolder', "Select a formatter"), activeItem: autoFocusItem });
if (!pick) {
// dismissed
return undefined;
Expand Down