Skip to content

Commit 483b98c

Browse files
committed
Fix: automatically re-sync Client when out of sync.
1 parent 296d50c commit 483b98c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

extensions/VSCode/src/extension.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,25 @@ export const activate = (context: vscode.ExtensionContext) => {
522522
// Report if this was an error.
523523
const result_contents = value as MessageResult;
524524
if ("Err" in result_contents) {
525-
show_error(
526-
`Error in message ${id}: ${JSON.stringify(result_contents.Err)}`,
527-
);
525+
const err = result_contents[
526+
"Err"
527+
] as ResultErrTypes;
528+
if (
529+
err instanceof Object &&
530+
"OutOfSync" in err
531+
) {
532+
// Send an update to re-sync the Client.
533+
console.warn(
534+
"Client is out of sync; resyncing.",
535+
);
536+
send_update(true);
537+
} else {
538+
// If the client is out of sync, re-sync it.
539+
if (result_contents)
540+
show_error(
541+
`Error in message ${id}: ${JSON.stringify(err)}`,
542+
);
543+
}
528544
}
529545
break;
530546
}

server/src/processing.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,8 @@ fn replace_math_node(child: &Rc<Node>, is_hydrate: bool) -> Option<Rc<Node>> {
11771177
// Final test: if the class is correct, this is math; otherwise, perform
11781178
// no transformation.
11791179
//
1180-
// Add/remove the `mceNonEditable` class to prevent accidental edits of this span.
1180+
// Add/remove the `mceNonEditable` class to prevent accidental edits of
1181+
// this span.
11811182
let attr_value_str: &str = attr_value;
11821183
let delim = if is_hydrate {
11831184
match attr_value_str {

0 commit comments

Comments
 (0)