Skip to content

Commit

Permalink
Fix double page reloads
Browse files Browse the repository at this point in the history
  • Loading branch information
zefhemel committed Sep 10, 2024
1 parent d9aa6ef commit d8b4295
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion web/editor_state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import customMarkdownStyle from "./style.ts";
import { history, indentWithTab, standardKeymap } from "@codemirror/commands";
import {
history,
indentWithTab,
isolateHistory,
standardKeymap,
} from "@codemirror/commands";
import {
autocompletion,
closeBrackets,
Expand Down Expand Up @@ -247,6 +252,12 @@ export function createEditorState(
class {
update(update: ViewUpdate): void {
if (update.docChanged) {
// Find if there's a history isolate in the transaction, if so it came from a local reload and we don't do anything
if (
update.transactions.some((t) => t.annotation(isolateHistory))
) {
return;
}
const changes: TextChange[] = [];
update.changes.iterChanges((fromA, toA, fromB, toB, inserted) =>
changes.push({
Expand Down

0 comments on commit d8b4295

Please sign in to comment.