Fix double page reloads
parent
d9aa6ef1c4
commit
d8b4295af4
|
@ -1,5 +1,10 @@
|
||||||
import customMarkdownStyle from "./style.ts";
|
import customMarkdownStyle from "./style.ts";
|
||||||
import { history, indentWithTab, standardKeymap } from "@codemirror/commands";
|
import {
|
||||||
|
history,
|
||||||
|
indentWithTab,
|
||||||
|
isolateHistory,
|
||||||
|
standardKeymap,
|
||||||
|
} from "@codemirror/commands";
|
||||||
import {
|
import {
|
||||||
autocompletion,
|
autocompletion,
|
||||||
closeBrackets,
|
closeBrackets,
|
||||||
|
@ -247,6 +252,12 @@ export function createEditorState(
|
||||||
class {
|
class {
|
||||||
update(update: ViewUpdate): void {
|
update(update: ViewUpdate): void {
|
||||||
if (update.docChanged) {
|
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[] = [];
|
const changes: TextChange[] = [];
|
||||||
update.changes.iterChanges((fromA, toA, fromB, toB, inserted) =>
|
update.changes.iterChanges((fromA, toA, fromB, toB, inserted) =>
|
||||||
changes.push({
|
changes.push({
|
||||||
|
|
Loading…
Reference in New Issue