A3: singular and plural counts in the Problems window
The summary and the per-file count tooltip pick one/other catalog
messages ("1 error", "3 errors") instead of the plural-free wording.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
765dbf71b7
commit
af24899ac5
3 changed files with 35 additions and 7 deletions
|
|
@ -68,13 +68,27 @@ const status = computed(() => {
|
|||
return t("problems.empty");
|
||||
}
|
||||
const c = problems.counts;
|
||||
const others = c.info + c.hint;
|
||||
return t("problems.summary", {
|
||||
errors: String(c.error),
|
||||
warnings: String(c.warning),
|
||||
infos: String(c.info + c.hint),
|
||||
errors:
|
||||
c.error === 1 ? t("problems.count.error.one") : t("problems.count.error.other", { count: String(c.error) }),
|
||||
warnings:
|
||||
c.warning === 1
|
||||
? t("problems.count.warning.one")
|
||||
: t("problems.count.warning.other", { count: String(c.warning) }),
|
||||
infos: t("problems.count.other", { count: String(others) }),
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* The tooltip of a file's problem count, singular for one.
|
||||
*
|
||||
* @param count - the file's problems.
|
||||
*/
|
||||
function fileCountTitle(count: number): string {
|
||||
return count === 1 ? t("problems.file.count.one") : t("problems.file.count.other", { count: String(count) });
|
||||
}
|
||||
|
||||
/** A file with its rows and their indexes in the flat list. */
|
||||
interface ProblemGroup {
|
||||
/** Project-relative path. */
|
||||
|
|
@ -238,7 +252,7 @@ watch(
|
|||
<span class="problems__file-dir">{{ dirName(group.path) }}</span>
|
||||
<span
|
||||
class="problems__file-count"
|
||||
:title="t('problems.file.count', { count: String(group.rows.length) })"
|
||||
:title="fileCountTitle(group.rows.length)"
|
||||
>{{ group.rows.length }}</span>
|
||||
</div>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -208,8 +208,14 @@
|
|||
"palette.label": "Command palette",
|
||||
"palette.noMatches": "No matching commands",
|
||||
"palette.placeholder": "Type a command name",
|
||||
"problems.count.error.one": "1 error",
|
||||
"problems.count.error.other": "{count} errors",
|
||||
"problems.count.other": "{count} other",
|
||||
"problems.count.warning.one": "1 warning",
|
||||
"problems.count.warning.other": "{count} warnings",
|
||||
"problems.empty": "No problems found in open files",
|
||||
"problems.file.count": "{count} problems",
|
||||
"problems.file.count.one": "1 problem",
|
||||
"problems.file.count.other": "{count} problems",
|
||||
"problems.list.label": "Problems of the project",
|
||||
"problems.lsp.failed": "Phpactor stopped: {message}",
|
||||
"problems.lsp.progress.label": "Language server: {title}",
|
||||
|
|
@ -223,7 +229,7 @@
|
|||
"problems.severity.hint": "Hint",
|
||||
"problems.severity.info": "Information",
|
||||
"problems.severity.warning": "Warning",
|
||||
"problems.summary": "Errors: {errors}, warnings: {warnings}, other: {infos}",
|
||||
"problems.summary": "{errors}, {warnings}, {infos}",
|
||||
"problems.toolWindow.title": "Problems",
|
||||
"project.empty.noFolder": "No folder is open.",
|
||||
"project.openFolder": "Open Folder…",
|
||||
|
|
|
|||
|
|
@ -211,7 +211,15 @@ describe("ProblemsToolWindow", () => {
|
|||
items: [diag(4, "warning", "Unused variable"), { ...diag(1, "error", "Undefined method"), code: "E12" }],
|
||||
});
|
||||
await emit({ kind: "diagnosticsChanged", path: "a.php", items: [diag(0, "hint", "Could be final")] });
|
||||
expect(wrapper.get("[data-test=problems-status]").text()).toBe("Errors: 1, warnings: 1, other: 1");
|
||||
expect(wrapper.get("[data-test=problems-status]").text()).toBe("1 error, 1 warning, 1 other");
|
||||
expect(wrapper.findAll(".problems__file-count").map((c) => c.attributes("title"))).toEqual(["1 problem", "2 problems"]);
|
||||
await emit({
|
||||
kind: "diagnosticsChanged",
|
||||
path: "b.php",
|
||||
items: [diag(0, "error", "One"), diag(1, "error", "Two")],
|
||||
});
|
||||
expect(wrapper.get("[data-test=problems-status]").text()).toBe("3 errors, 1 warning, 1 other");
|
||||
await emit({ kind: "diagnosticsChanged", path: "b.php", items: [] });
|
||||
const files = wrapper.findAll("[data-test=problems-file]").map((f) => f.text());
|
||||
expect(files[0]).toContain("a.php");
|
||||
expect(files[1]).toContain("Service.php");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue