aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail-overview/Accounts.qml49
-rw-r--r--mail-overview/shell.qml1
2 files changed, 31 insertions, 19 deletions
diff --git a/mail-overview/Accounts.qml b/mail-overview/Accounts.qml
index 1bb451f..27cdcf9 100644
--- a/mail-overview/Accounts.qml
+++ b/mail-overview/Accounts.qml
@@ -66,28 +66,39 @@ Singleton {
}
// Sections in file order, which is the display order.
+ //
+ // A line walk rather than one regex over the whole file. The obvious
+ // pattern for a section body, "everything up to the next [", is wrong
+ // here: several accounts carry folder names like "[Gmail]/Bozze", so the
+ // body ended before its label and three of five accounts silently fell
+ // back to displaying their key. Walking lines says what it means, and the
+ // only state is which section we are in.
function parseAccounts(conf) {
const out = [];
- // QML's JS engine has no String.matchAll, so this is an exec loop.
- // At least one key contains a dot of its own, so the key runs to the
- // closing bracket rather than to the first dot.
- const re = /^\[account\.([^\]]+)\]([^\[]*)/gm;
- let m;
- while ((m = re.exec(conf)) !== null) {
- const key = m[1];
- const body = m[2];
- const field = name => {
- const f = body.match(new RegExp(`^\\s*${name}\\s*=\\s*(.+)$`, "m"));
- return f ? f[1].trim() : "";
- };
- out.push({
- key: key,
- label: field("label") || key,
- color: field("color"),
- count: -1,
- threads: [],
- });
+ let cur = null;
+
+ for (const line of conf.split("\n")) {
+ // At least one key contains a dot of its own, so the key runs to
+ // the closing bracket rather than to the first dot.
+ const header = line.match(/^\[account\.([^\]]+)\]/);
+ if (header) {
+ cur = { key: header[1], label: "", color: "", count: -1, threads: [] };
+ out.push(cur);
+ continue;
+ }
+ // Any other section ends the current account.
+ if (line.startsWith("[")) {
+ cur = null;
+ continue;
+ }
+ if (!cur) continue;
+
+ const field = line.match(/^\s*(label|color)\s*=\s*(.+)$/);
+ if (field) cur[field[1]] = field[2].trim();
}
+
+ // A missing label shows the key, which is ugly but true.
+ for (const a of out) if (!a.label) a.label = a.key;
return out;
}
diff --git a/mail-overview/shell.qml b/mail-overview/shell.qml
index 1925f44..7842bc6 100644
--- a/mail-overview/shell.qml
+++ b/mail-overview/shell.qml
@@ -11,6 +11,7 @@
import Quickshell
import Quickshell.Io
+import QtQuick
ShellRoot {
MailPanel { id: panel }