Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/lib/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

export const appendS: (obj: any[] | number, str: string) => string = (obj: any[] | number, str: string) => Array.isArray(obj) ? appendS(obj.length, str) : `${obj} ${str}${obj != 1 ? 's' : ''}`;
export const appendS: (obj: any[] | number, str: string) => string = (obj: any[] | number, str: string) =>
Array.isArray(obj) ? appendS(obj.length, str) : `${obj} ${str}${obj != 1 ? 's' : ''}`;

export const capitalize: (s: string) => string = (s: string) => `${(s[0] ?? "").toUpperCase() + (s ?? "").substring(1)}`;
export const appendIf: (s: string, condition: (s: string) => boolean, append: string) => string = (s: string, condition: (s: string) => boolean, append: string) =>
s + (condition(s) ? append : '');

export const capitalize: (s: string) => string = (s: string) =>
`${(s[0] ?? "").toUpperCase() + (s ?? "").substring(1)}`;
4 changes: 2 additions & 2 deletions src/menu/align.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const show: (ui: UI) => void = (ui: UI) => {
// manual
separator(),
quickPickItem({ label: prop.items!.enum![9],
description: "Manual position",
description: `(${get("backgroundAlignmentValue", ui)})`,
ui,
handle: (item: CommandQuickPickItem) => {
const currentValue: string = get("backgroundAlignmentValue", ui);
Expand All @@ -75,7 +75,7 @@ export const show: (ui: UI) => void = (ui: UI) => {
}
});
}
})
}, current)
], {
title: title("Alignment", ui),
matchOnDescription: true,
Expand Down
6 changes: 3 additions & 3 deletions src/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { pkg } from "../extension/package";
import { UI, configuration, get } from "../extension/config";

import { count } from "../lib/glob";
import { capitalize, appendS } from "../lib/string";
import { appendS, appendIf, capitalize } from "../lib/string";
import { CommandQuickPickItem, quickPickItem, separator, showQuickPick } from "../lib/vscode"

import { show as fileMenu } from "./file";
Expand Down Expand Up @@ -134,7 +134,7 @@ export const open: (ui: UI) => void = (ui: UI) =>
separator(),
quickPickItem({
label: "$(arrow-both) Alignment",
description: `${get("backgroundAlignment", ui)}`,
description: `${appendIf(get("backgroundAlignment", ui), s => s === "Manual", ` (${get("backgroundAlignmentValue", ui)})`)}`,
detail: "Background image alignment",
ui,
handle: () => alignMenu(ui)
Expand Down Expand Up @@ -162,7 +162,7 @@ export const open: (ui: UI) => void = (ui: UI) =>
}),
quickPickItem({
label: "$(screen-full) Size",
description: `${get("backgroundSize", ui)}`,
description: `${appendIf(get("backgroundSize", ui), s => s === "Manual", ` (${get("backgroundSizeValue", ui)})`)}`,
detail: "Background image size",
ui,
handle: () => sizeMenu(ui)
Expand Down
2 changes: 1 addition & 1 deletion src/menu/size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const show: (ui: UI) => void = (ui: UI) => {
quickPickItem({ label: prop.items!.enum![2], description: prop.items!.enumDescriptions![2], handle, ui }, current),
separator(),
// manual
quickPickItem({ label: prop.items!.enum![3], description: prop.items!.enumDescriptions![3], ui: ui, handle: (item: CommandQuickPickItem) => {
quickPickItem({ label: prop.items!.enum![3], description: `(${get("backgroundSizeValue", ui)})`, ui: ui, handle: (item: CommandQuickPickItem) => {
const currentValue: string = get("backgroundSizeValue", ui);
showInputBox({
title: title("Size", ui),
Expand Down