Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HTML] server contains invalid implementation of applyEdit #45014

Closed
idanarye opened this issue Mar 4, 2018 · 4 comments
Closed

[HTML] server contains invalid implementation of applyEdit #45014

idanarye opened this issue Mar 4, 2018 · 4 comments
Assignees

Comments

@idanarye
Copy link

idanarye commented Mar 4, 2018

The protocol has changed to define that multiple edits can have the same position, and should be applied using the order inside the array. The current implementation in VSCode, however, is using unstable sort - meaning the order they will be applied in will be arbitrary.

Specifically, with one equivalence class TypeScript's current implementation of sort will reverse the array - which is exactly the opposite of what the specs specify.

To be compliant with the specs, VSCode must use stable sort on the edits.

@jrieken
Copy link
Member

jrieken commented Mar 5, 2018

I believe this is @dbaeumer or @aeschli and not the extension api. Fyi, for stable sorting there is arrays#mergeSort

@dbaeumer
Copy link
Member

dbaeumer commented Mar 5, 2018

@aeschli assigning to you since this is specifiic HTML code.

@idanarye the editor which usually applies these edits does us a stable sort. So the actual VS Code API is fine in that regard.

@dbaeumer dbaeumer assigned aeschli and unassigned dbaeumer Mar 5, 2018
@idanarye
Copy link
Author

idanarye commented Mar 5, 2018

@dbaeumer What do you mean by "the editor which usually applies these edits"? VSCode uses unstable sort (unless it overrides TypeScript's array#sort with a stable implementation?), and other editors, which looked at VSCode's behavior as reference, do a stable sort after reversing the edits - because this happens to be what the current implementation of array#sort does for a single equivalence class.

@dbaeumer
Copy link
Member

dbaeumer commented Mar 6, 2018

@idanarye VS Code offers API for extension to apply edits to an open buffer. When this API is called the editor itself sorts the array using a stable sort algorithm as defined in the LSP spec.

See: https://github.com/Microsoft/vscode/blob/master/src/vs/vscode.d.ts#L5556

@aeschli aeschli changed the title LSP spec was changed to support multiple edits at the same location - client in VSCode still orders them arbitrarily [HTML] server contains invalid implementation of applyEdit Mar 6, 2018
@aeschli aeschli closed this as completed in bde23fb Mar 6, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants