Skip to content

Commit

Permalink
Add import field to metadata to satisfy older versions (#11797)
Browse files Browse the repository at this point in the history
Fixes #11742

I was [wrong](#11742 (comment)) - 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.
  • Loading branch information
farmaazon authored Dec 6, 2024
1 parent c284bcb commit c410311
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/ydoc-server/src/edits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions app/ydoc-server/src/languageServerSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c410311

Please sign in to comment.