Fix notepad cursor and calculator linked formulas
All checks were successful
Deploy Sokko G / deploy (push) Successful in 16s

This commit is contained in:
Shinuwa 2026-08-20 16:16:24 +02:00
parent 992665f4ea
commit 49ba0c4cb2
10 changed files with 223 additions and 45 deletions

View file

@ -340,7 +340,8 @@ function exportCalculatorText(data) {
if (data.scrollResults) lines.push("@scrollResults: true");
function visit(parentId = "", depth = 0) {
(data.entries || []).filter((entry) => (entry.parentId || "") === parentId).forEach((entry) => {
lines.push(`${" ".repeat(depth)}${entry.label || ""}: ${entry.value}`);
const formula = String(entry.formula || "").trim();
lines.push(`${" ".repeat(depth)}${entry.label || ""}: ${entry.value}${formula ? ` | formula=${formula}` : ""}`);
visit(entry.id, depth + 1);
});
}
@ -363,9 +364,10 @@ function importCalculatorText(text, context) {
const separatorIndex = line.indexOf(":");
if (separatorIndex < 0) throw lineError(index, `ligne calculateur invalide: ${line.trim()}`);
const label = line.slice(0, separatorIndex).trim();
const value = parseNumber(line.slice(separatorIndex + 1), Number.NaN);
const [rawValue, rawFormula = ""] = line.slice(separatorIndex + 1).split(/\s+\|\s+formula=/);
const value = parseNumber(rawValue, Number.NaN);
if (!Number.isFinite(value)) throw lineError(index, `valeur calculateur invalide: ${line.trim()}`);
const entry = { id: context.uid("calc"), parentId: parentStack[depth - 1] || "", label, value };
const entry = { id: context.uid("calc"), parentId: parentStack[depth - 1] || "", label, value, formula: rawFormula.trim() };
entries.push(entry);
parentStack[depth] = entry.id;
parentStack.length = depth + 1;