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

Cannot get didChange with incremental changes to work #1633

Open
NGPixel opened this issue Feb 26, 2024 · 3 comments
Open

Cannot get didChange with incremental changes to work #1633

NGPixel opened this issue Feb 26, 2024 · 3 comments

Comments

@NGPixel
Copy link

NGPixel commented Feb 26, 2024

When sending the textDocument/didChange with the full document text (without range and rangeLength properties), the content gets properly updated in Lemminx. Calling something like textDocument/formatting afterwards correctly returns the proper changes.

However, if I try to use incremental sync, adding the range (and optionally the rangeLength) properties and only set the text that changed, it gets completely ignored. Calling something like textDocument/formatting assumes the very first version of the document and not the changes that were applied afterwards.

Is there something obvious I'm missing that needs to be done for incremental changes to be supported in Lemminx?

For reference, here's an example request for an incremental change:

{
  "jsonrpc": "2.0",
  "method": "textDocument/didChange",
  "params": {
    "textDocument": {
      "uri": "file:///c%3A%5CUsers%5Cnick%5Ctest%5Cdraft-07.xml",
      "version": 1
    },
    "contentChanges": [
      {
        "range": {
          "start": {
            "line": 26,
            "character": 4
          },
          "end": {
            "line": 26,
            "character": 4
          }
        },
        "rangeLength": 0,
        "text": "Introduction"
      }
    ]
  }
}

This is the lsp lifecycle I have:

  • --> initialize
  • <-- server capabilities (with "textDocumentSync":2)
  • --> initialized
  • --> textDocument/didOpen
  • <-- textDocument/publishDiagnostics
  • --> textDocument/didChange
@angelozerr
Copy link
Contributor

I suggest you that you install vscode xml and you enable trace and study the traces since it is working with incremental support in vscode

@buhl-tax-service
Copy link

@NGPixel Did you fix the problem? I have the same issue.

@NGPixel
Copy link
Author

NGPixel commented Jun 12, 2024

@buhl-tax-service I don't recall what exactly was breaking it, but here's my current code that works:

https://github.com/ietf-tools/editor/blob/f4b82c127ae5bf3e6689f5e4dd29e259da0dac56/src/stores/docs.js#L210-L250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants