Skip to content

Make it clearer the responsibilities/gurantees for orders of multiple text edits #888

@DanTup

Description

@DanTup

This was discussed a little in #279, including this comment from @dbaeumer:

The burden of doing the right thing is basically pushed to the too (e.g. client)

the changes should be applied in the order in which they are sent

So there is no need to order the edits

My understanding of these three is that the client must send these edits in offset-descending order (despite the fact that semantically the order should not matter, because the offsets are based on the original document). However I don't think this is clear from the spec:

 	/**
	 * The actual content changes. The content changes describe single state changes
	 * to the document. So if there are two content changes c1 and c2 for a document
	 * in state S then c1 move the document to S' and c2 to S''.
	 */

It's possible this says the same thing, but it's not very clear to me (so it might not be to some other devs). I think it should be very explicit whether it is required for the client to send the edits in reverse-offset order (or if they're not, that a server should handle them in the wrong order).

VS Code had a bug around this (microsoft/vscode#88570) where some extensions were mutating the edits and they arrived to other extensions in the wrong order (I would presume that the Node LSP client was also effected unless it's manually sorting the edits before sending) and it's still not clear where the responsibilities lie (I asked for clarification, but the issue was just closed). I think the less ambiguity in the specs, the less likely bugs like this will crop up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions