Skip to content

Commit 6c8f633

Browse files
committed
Fix: send autosave data when doc blocks receive focus.
1 parent 2c428db commit 6c8f633

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Changelog
2323
--------------------------------------------------------------------------------
2424

2525
* Block drag and drop of images, which creates a mess.
26+
* Send sync data when doc blocks receive focus.
2627

2728
Version 0.1.41 -- 2025-Nov-17
2829
--------------------------------------------------------------------------------

client/src/CodeChatEditor.mts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,14 @@ const on_save = async (only_if_dirty: boolean = false) => {
368368
if (only_if_dirty && !is_dirty) {
369369
return;
370370
}
371+
clearAutosaveTimer();
372+
371373
// <a id="save"></a>Save the provided contents back to the filesystem, by
372374
// sending an update message over the websocket.
373375
const webSocketComm = parent.window.CodeChatEditorFramework.webSocketComm;
374-
console_log("CodeChat Editor Client: sent Update - saving document.");
376+
console_log(
377+
"CodeChat Editor Client: sent Update - saving document/updating cursor location.",
378+
);
375379
await new Promise(async (resolve) => {
376380
webSocketComm.send_message({ Update: save_lp(is_dirty) }, () =>
377381
resolve(0),

client/src/CodeMirror-integration.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,9 @@ export const DocBlockPlugin = ViewPlugin.fromClass(
724724
}
725725
const [contents_div, is_tinymce] = get_contents(target);
726726

727+
// Send updated cursor/scroll info.
728+
startAutosaveTimer();
729+
727730
// See if this is already a TinyMCE instance; if not, move it
728731
// here.
729732
if (is_tinymce) {

0 commit comments

Comments
 (0)