Fix double page reloads

lua
Zef Hemel 2024-09-10 14:54:15 +02:00
parent d9aa6ef1c4
commit d8b4295af4
1 changed files with 12 additions and 1 deletions

View File

@ -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,
@ -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({