Skip to content

Commit

Permalink
Automate border choice (#29096)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Aug 10, 2018
1 parent 26a756c commit 87f890a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/vs/platform/quickinput/common/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export interface IQuickPickItem {

export interface IQuickPickSeparator {
type: 'separator';
border?: boolean;
label?: string;
}

Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/browser/parts/editor/editorStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ export class ChangeModeAction extends Action {
});

if (hasLanguageSupport) {
picks.unshift({ type: 'separator', border: true, label: nls.localize('languagesPicks', "languages (identifier)") });
picks.unshift({ type: 'separator', label: nls.localize('languagesPicks', "languages (identifier)") });
}

// Offer action to configure via settings
Expand Down Expand Up @@ -1079,7 +1079,7 @@ class ChangeIndentationAction extends Action {
};
});

picks.splice(3, 0, { type: 'separator', label: nls.localize('indentConvert', "convert file"), border: true });
picks.splice(3, 0, { type: 'separator', label: nls.localize('indentConvert', "convert file") });
picks.unshift({ type: 'separator', label: nls.localize('indentView', "change view") });

return this.quickInputService.pick(picks, { placeHolder: nls.localize('pickAction', "Select Action"), matchOnDetail: true }).then(action => action && action.run());
Expand Down Expand Up @@ -1231,7 +1231,7 @@ export class ChangeEncodingAction extends Action {

// If we have a guessed encoding, show it first unless it matches the configured encoding
if (guessedEncoding && configuredEncoding !== guessedEncoding && SUPPORTED_ENCODINGS[guessedEncoding]) {
picks.unshift({ type: 'separator', border: true });
picks.unshift({ type: 'separator' });
picks.unshift({ id: guessedEncoding, label: SUPPORTED_ENCODINGS[guessedEncoding].labelLong, description: nls.localize('guessedEncoding', "Guessed from content") });
}

Expand Down
16 changes: 10 additions & 6 deletions src/vs/workbench/browser/parts/quickinput/quickInput.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,22 @@
}

.quick-input-list .quick-input-list-entry {
box-sizing: border-box;
overflow: hidden;
display: flex;
height: 100%;
padding: 0 6px;
}

.quick-input-list .quick-input-list-entry.quick-input-list-separator-border {
border-top-width: 1px;
border-top-style: solid;
}

.quick-input-list .monaco-list-row:first-child .quick-input-list-entry.quick-input-list-separator-border {
border-top-style: none;
}

.quick-input-list .quick-input-list-label {
overflow: hidden;
display: flex;
Expand Down Expand Up @@ -179,12 +189,6 @@
margin-right: 0;
}

.quick-input-list .quick-input-list-separator-border {
border-top-width: 1px;
border-top-style: solid;
box-sizing: border-box;
}

.quick-input-list .quick-input-list-entry-action-bar {
display: none;
flex: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ListElementRenderer implements IRenderer<ListElement, IListElementTemplate
} else {
data.separator.style.display = 'none';
}
if (element.separator && element.separator.border) {
if (element.separator) {
dom.addClass(data.entry, 'quick-input-list-separator-border');
} else {
dom.removeClass(data.entry, 'quick-input-list-separator-border');
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-browser/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ export abstract class BaseOpenRecentAction extends Action {

let keyMods: IKeyMods;
const workspaceSeparator: IQuickPickSeparator = { type: 'separator', label: nls.localize('workspaces', "workspaces") };
const fileSeparator: IQuickPickSeparator = { type: 'separator', label: nls.localize('files', "files"), border: true };
const fileSeparator: IQuickPickSeparator = { type: 'separator', label: nls.localize('files', "files") };
const picks = [workspaceSeparator, ...workspacePicks, fileSeparator, ...filePicks];
this.quickInputService.pick(picks, {
contextKey: inRecentFilesPickerContextKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class ConfigurationManager implements IConfigurationManager {

candidates = candidates.sort((first, second) => first.label.localeCompare(second.label));
const picks = candidates.map(c => ({ label: c.label, debugger: c }));
return this.quickInputService.pick<(typeof picks)[0]>([...picks, { type: 'separator', border: true }, { label: 'More...', debugger: undefined }], { placeHolder: nls.localize('selectDebug', "Select Environment") })
return this.quickInputService.pick<(typeof picks)[0]>([...picks, { type: 'separator' }, { label: 'More...', debugger: undefined }], { placeHolder: nls.localize('selectDebug', "Select Environment") })
.then(picked => {
if (picked.debugger) {
return picked.debugger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ CommandsRegistry.registerCommand(id, async accessor => {
const newGlobalPick = <IQuickPickItem>{ label: nls.localize('new.global', "New Global Snippets file...") };
if (existing.length > 0) {
existing.unshift({ type: 'separator', label: nls.localize('group.global', "Existing Snippets") });
existing.push({ type: 'separator', border: true, label: nls.localize('new.global.sep', "New Snippets") });
existing.push({ type: 'separator', label: nls.localize('new.global.sep', "New Snippets") });
} else {
existing.push({ type: 'separator', label: nls.localize('new.global.sep', "New Snippets") });
}
Expand Down
18 changes: 8 additions & 10 deletions src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ class TaskService implements ITaskService {
}
if (entries.length > 0) {
entries = entries.sort((a, b) => a.label.localeCompare(b.label));
entries.unshift({ type: 'separator', border: true, label: nls.localize('TaskService.associate', 'associate') });
entries.unshift({ type: 'separator', label: nls.localize('TaskService.associate', 'associate') });
entries.unshift(
{ label: nls.localize('TaskService.attachProblemMatcher.continueWithout', 'Continue without scanning the task output'), matcher: undefined },
{ label: nls.localize('TaskService.attachProblemMatcher.never', 'Never scan the task output'), matcher: undefined, never: true },
Expand Down Expand Up @@ -1804,9 +1804,9 @@ class TaskService implements ITaskService {
}
return { label: task._label, description, task };
};
function fillEntries(entries: QuickPickInput<TaskQuickPickEntry>[], tasks: Task[], groupLabel: string, withBorder: boolean = false): void {
function fillEntries(entries: QuickPickInput<TaskQuickPickEntry>[], tasks: Task[], groupLabel: string): void {
if (tasks.length) {
entries.push({ type: 'separator', label: groupLabel, border: withBorder });
entries.push({ type: 'separator', label: groupLabel });
}
for (let task of tasks) {
let entry: TaskQuickPickEntry = TaskQuickPickEntry(task);
Expand Down Expand Up @@ -1848,13 +1848,11 @@ class TaskService implements ITaskService {
}
}
const sorter = this.createSorter();
let hasRecentlyUsed: boolean = recent.length > 0;
fillEntries(entries, recent, nls.localize('recentlyUsed', 'recently used tasks'));
configured = configured.sort((a, b) => sorter.compare(a, b));
let hasConfigured = configured.length > 0;
fillEntries(entries, configured, nls.localize('configured', 'configured tasks'), hasRecentlyUsed);
fillEntries(entries, configured, nls.localize('configured', 'configured tasks'));
detected = detected.sort((a, b) => sorter.compare(a, b));
fillEntries(entries, detected, nls.localize('detected', 'detected tasks'), hasRecentlyUsed || hasConfigured);
fillEntries(entries, detected, nls.localize('detected', 'detected tasks'));
}
} else {
if (sort) {
Expand Down Expand Up @@ -2274,7 +2272,7 @@ class TaskService implements ITaskService {
if (needsCreateOrOpen) {
let label = stats[0] !== void 0 ? openLabel : createLabel;
if (entries.length) {
entries.push({ type: 'separator', border: true });
entries.push({ type: 'separator' });
}
entries.push({ label, folder: this.contextService.getWorkspace().folders[0] });
}
Expand All @@ -2288,14 +2286,14 @@ class TaskService implements ITaskService {
for (let i = 0; i < tasks.length; i++) {
let entry: EntryType = { label: tasks[i]._label, task: tasks[i], description: folder.name };
if (i === 0) {
entries.push({ type: 'separator', label: folder.name, border: index > 0 });
entries.push({ type: 'separator', label: folder.name });
}
entries.push(entry);
}
} else {
let label = stats[index] !== void 0 ? openLabel : createLabel;
let entry: EntryType = { label, folder: folder };
entries.push({ type: 'separator', label: folder.name, border: index > 0 });
entries.push({ type: 'separator', label: folder.name });
entries.push(entry);
}
index++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export class SelectColorThemeAction extends Action {

const picks: QuickPickInput[] = [].concat(
toEntries(themes.filter(t => t.type === LIGHT), localize('themes.category.light', "light themes")),
toEntries(themes.filter(t => t.type === DARK), localize('themes.category.dark', "dark themes"), true),
toEntries(themes.filter(t => t.type === HIGH_CONTRAST), localize('themes.category.hc', "high contrast themes"), true),
toEntries(themes.filter(t => t.type === DARK), localize('themes.category.dark', "dark themes")),
toEntries(themes.filter(t => t.type === HIGH_CONTRAST), localize('themes.category.hc', "high contrast themes")),
configurationEntries(this.extensionGalleryService, localize('installColorThemes', "Install Additional Color Themes..."))
);

Expand Down Expand Up @@ -153,8 +153,7 @@ function configurationEntries(extensionGalleryService: IExtensionGalleryService,
if (extensionGalleryService.isEnabled()) {
return [
{
type: 'separator',
border: true
type: 'separator'
},
{
id: void 0,
Expand All @@ -173,12 +172,12 @@ function openExtensionViewlet(viewletService: IViewletService, query: string) {
});
}

function toEntries(themes: (IColorTheme | IFileIconTheme)[], label?: string, border = false) {
function toEntries(themes: (IColorTheme | IFileIconTheme)[], label?: string) {
const toEntry = theme => <IQuickPickItem>{ id: theme.id, label: theme.label, description: theme.description };
const sorter = (t1: IQuickPickItem, t2: IQuickPickItem) => t1.label.localeCompare(t2.label);
let entries: QuickPickInput[] = themes.map(toEntry).sort(sorter);
if (entries.length > 0 && (label || border)) {
entries.unshift({ type: 'separator', label, border });
if (entries.length > 0 && label) {
entries.unshift({ type: 'separator', label });
}
return entries;
}
Expand Down

0 comments on commit 87f890a

Please sign in to comment.