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

Clarify how multiple TextEdits should be resolved when given in batch #104

Closed
rictic opened this issue Oct 23, 2016 · 2 comments
Closed

Comments

@rictic
Copy link
Contributor

rictic commented Oct 23, 2016

If I have a file with contents 012 and a completion is applied with two text edits:

  • Replace the zeroth character with two characters
  • Deleted the third character

Does that mean that 1 should be deleted, or 2?

More precisely, after applying these TextEdits:

  [
    {range: {start: {line: 0, column: 0}, end: {line: 0, column: 1}, newText: 'aa'},
    {range: {start: {line: 0, column: 2}, end: {line: 0, column: 3}, newText: ''},
  ]

Should the resulting document have contents aa2 or aa1?

@kaloyan-raev
Copy link

As far as I am familiar with existing language server implementations, all TextEdits are based on the original, yet unmodified document.

So, in you example the resulting document would be aa1.

An appropriate order to apply the TextEdits to the document would be backwards. Apply the last one first, then the previous one, and so on... the first one is applied last. This way no shifting of not-yet-applied TextEdits would be necessary.

@dbaeumer
Copy link
Member

@kaloyan-raev is correct. Updated the protocol.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 21, 2017
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

3 participants