From c410311b15e461ab75d757cc2426793baf2f9e4f Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Fri, 6 Dec 2024 15:47:02 +0100 Subject: [PATCH] Add import field to metadata to satisfy older versions (#11797) Fixes #11742 I was [wrong](https://github.com/enso-org/enso/issues/11742#issuecomment-2514109015) - not the _new_ fields make metadata broken for older versions, but removing an _old_ field. This PR bring it back, which solves the issue - for a while. --- app/ydoc-server/src/edits.ts | 6 +++++- app/ydoc-server/src/languageServerSession.ts | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/ydoc-server/src/edits.ts b/app/ydoc-server/src/edits.ts index 82038b6b88..6bccdd3770 100644 --- a/app/ydoc-server/src/edits.ts +++ b/app/ydoc-server/src/edits.ts @@ -74,7 +74,11 @@ export function applyDocumentUpdates( if (codeChanged || idsChanged || metadataChanged) { // Update the metadata object. // Depth-first key order keeps diffs small. - newMetadata = { node: {}, widget: {} } + newMetadata = { + node: {}, + widget: {}, + import: {}, // "import" is required by older versions (even though they don't use it) + } root.visitRecursive(ast => { let pos = ast.nodeMetadata.get('position') const vis = ast.nodeMetadata.get('visualization') diff --git a/app/ydoc-server/src/languageServerSession.ts b/app/ydoc-server/src/languageServerSession.ts index 1ee21c961c..5005d4b9b8 100644 --- a/app/ydoc-server/src/languageServerSession.ts +++ b/app/ydoc-server/src/languageServerSession.ts @@ -350,7 +350,7 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> { // @ts-expect-error This is SAFE. `this.state` is only `readonly` to ensure that // this is the only place where it is mutated. this.state = state - if (state === LsSyncState.Synchronized) this.trySyncRemoveUpdates() + if (state === LsSyncState.Synchronized) this.trySyncRemoteUpdates() } else { throw new Error('LsSync disposed') } @@ -450,10 +450,10 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> { } else { this.updateToApply = update } - this.trySyncRemoveUpdates() + this.trySyncRemoteUpdates() } - trySyncRemoveUpdates() { + trySyncRemoteUpdates() { if (this.updateToApply == null) return // apply updates to the ls-representation doc if we are already in sync with the LS. if (!this.inState(LsSyncState.Synchronized)) return