From bc62e6ca2e64f974f51485542e4141eb1452537c Mon Sep 17 00:00:00 2001 From: Chris McCormick Date: Thu, 1 Jan 2026 14:03:15 +0800 Subject: [PATCH] Instant update on change. --- index.html | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index d18fe3d..4cf2e17 100644 --- a/index.html +++ b/index.html @@ -623,25 +623,8 @@ chmod 755 kbtd`; // --- File Operations --- - async function writeFile(text) { - try { - const writable = await state.fileHandle.createWritable(); - await writable.write(text); - await writable.close(); - console.log('File written successfully'); - - const file = await state.fileHandle.getFile(); - state.lastModified = file.lastModified; - - reloadFromText(text); - } catch (err) { - console.error('Error writing file:', err); - alert('Error saving file.'); - } - } - function reloadFromText(text) { - console.log('Reloading from text after write'); + console.log('Reloading from text'); state.sections = parseMarkdown(text); console.log('Parsed sections:', state.sections); @@ -652,6 +635,24 @@ chmod 755 kbtd`; } } + async function writeFile(text) { + try { + console.log('Writing file and updating UI'); + reloadFromText(text); + + const writable = await state.fileHandle.createWritable(); + await writable.write(text); + await writable.close(); + console.log('File written successfully'); + + const file = await state.fileHandle.getFile(); + state.lastModified = file.lastModified; + } catch (err) { + console.error('Error writing file:', err); + alert('Error saving file.'); + } + } + async function updateLineInFile(lineNum, newText) { console.log('updateLineInFile:', lineNum, newText); const file = await state.fileHandle.getFile();