Revert "Persist a subset of IdMap (#10347)" (#10626)

This reverts commit b2c4559678.

Merging as just failing the Vector tests addressed in another PR.
This commit is contained in:
Hubert Plociniczak 2024-07-22 18:24:13 +02:00 committed by GitHub
parent e02d5d431d
commit 033e4ae323
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 42 deletions

View File

@ -14,8 +14,6 @@ import type {
ExpressionId,
FileEdit,
FileSystemObject,
IdMapTriple,
IdMapTuple,
Notifications,
Path,
RegisterOptions,
@ -290,12 +288,8 @@ export class LanguageServer extends ObservableV2<Notifications & TransportEvents
}
/** [Documentation](https://github.com/enso-org/enso/blob/develop/docs/language-server/protocol-language-server.md#textapplyedit) */
applyEdit(
edit: FileEdit,
execute: boolean,
idMap?: IdMapTriple[] | IdMapTuple[],
): Promise<LsRpcResult<void>> {
return this.request('text/applyEdit', { edit, execute, idMap })
applyEdit(edit: FileEdit, execute: boolean): Promise<LsRpcResult<void>> {
return this.request('text/applyEdit', { edit, execute })
}
/** [Documentation](https://github.com/enso-org/enso/blob/develop/docs/language-server/protocol-language-server.md#filewrite) */

View File

@ -74,15 +74,6 @@ export interface Position {
character: number
}
interface IdMapSpan {
index: { value: number }
size: { value: number }
}
export type IdMapTuple = [IdMapSpan, string]
export type IdMapTriple = [number, number, string]
export type RegisterOptions = { path: Path } | { contextId: ContextId } | {}
export interface CapabilityRegistration {

View File

@ -34,7 +34,7 @@ import {
translateVisualizationFromFile,
} from './edits'
import * as fileFormat from './fileFormat'
import { deserializeIdMap, idMapToArray, serializeIdMap } from './serialization'
import { deserializeIdMap, serializeIdMap } from './serialization'
import { WSSharedDoc } from './ydoc'
const SOURCE_DIR = 'src'
@ -457,18 +457,6 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> {
}
}
private static getIdMapToPersist(
idMap: IdMap | undefined,
metadata: fileFormat.IdeMetadata['node'],
): IdMap | undefined {
if (idMap === undefined) {
return
} else {
const entriesIntersection = idMap.entries().filter(([, id]) => id in metadata)
return new IdMap(entriesIntersection)
}
}
private sendLsUpdate(
synced: EnsoFileParts,
newCode: string | undefined,
@ -480,17 +468,11 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> {
const code = newCode ?? synced.code
const newMetadataJson =
newMetadata &&
json.stringify({
...this.syncedMeta,
ide: { ...this.syncedMeta.ide, node: newMetadata },
})
const idMapToPersist =
(newIdMap || newMetadata) &&
ModulePersistence.getIdMapToPersist(newIdMap, newMetadata ?? this.syncedMeta.ide.node)
const newIdMapToPersistJson = idMapToPersist && serializeIdMap(idMapToPersist)
json.stringify({ ...this.syncedMeta, ide: { ...this.syncedMeta.ide, node: newMetadata } })
const newIdMapJson = newIdMap && serializeIdMap(newIdMap)
const newContent = combineFileParts({
code,
idMapJson: newIdMapToPersistJson ?? synced.idMapJson ?? '[]',
idMapJson: newIdMapJson ?? synced.idMapJson ?? '[]',
metadataJson: newMetadataJson ?? synced.metadataJson ?? '{}',
})
@ -520,7 +502,7 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> {
const execute = newCode != null || newIdMap != null
const edit: FileEdit = { path: this.path, edits, oldVersion: this.syncedVersion, newVersion }
const apply = this.ls.applyEdit(edit, execute, newIdMap && idMapToArray(newIdMap))
const apply = this.ls.applyEdit(edit, execute)
const handleError = (error: unknown) => {
console.error('Could not apply edit:', error)
// Try to recover by reloading the file.
@ -539,7 +521,7 @@ class ModulePersistence extends ObservableV2<{ removed: () => void }> {
this.syncedVersion = newVersion
if (newMetadata) this.syncedMeta.ide.node = newMetadata
if (newCode) this.syncedCode = newCode
if (newIdMapToPersistJson) this.syncedIdMap = newIdMapToPersistJson
if (newIdMapJson) this.syncedIdMap = newIdMapJson
if (newMetadataJson) this.syncedMetaJson = newMetadataJson
this.setState(LsSyncState.Synchronized)
}, handleError)

View File

@ -23,7 +23,7 @@ export function serializeIdMap(map: IdMap): string {
return json.stringify(idMapToArray(map))
}
export function idMapToArray(map: IdMap): fileFormat.IdMapEntry[] {
function idMapToArray(map: IdMap): fileFormat.IdMapEntry[] {
const entries: fileFormat.IdMapEntry[] = []
map.entries().forEach(([rangeBuffer, id]) => {
const decoded = sourceRangeFromKey(rangeBuffer)