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

textDocument/didChange Did not follow the LSP protocol #45

Closed
vincentLiuxiang opened this issue Jan 29, 2018 · 8 comments
Closed

textDocument/didChange Did not follow the LSP protocol #45

vincentLiuxiang opened this issue Jan 29, 2018 · 8 comments
Labels

Comments

@vincentLiuxiang
Copy link

hi all, I just want to try lsp in monaco, and I was very excited to find this project.
However, When I tried to analyze the websocket data package, I found a bug.

image

then, I tried to analyze theia-ide, It works fine.

image

what should I do to solve this problem?

@akosyakov
Copy link
Contributor

akosyakov commented Jan 29, 2018

Hi @vincentLiuxiang, could you be more specific what does not follow the LSP?

@vincentLiuxiang
Copy link
Author

@akosyakov
You can look at the red square inside the pictures.
textDocument/didChange

In LSP, when the method is textDocument/didChange, the params must be DidChangeTextDocumentParams

interface DidChangeTextDocumentParams {
	/**
	 * The document that did change. The version number points
	 * to the version after all provided content changes have
	 * been applied.
	 */
	textDocument: VersionedTextDocumentIdentifier;

	/**
	 * 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 S10 then c1 move the document to S11 and c2 to S12.
	 */
	contentChanges: TextDocumentContentChangeEvent[];
}

/**
 * An event describing a change to a text document. If range and rangeLength are omitted
 * the new text is considered to be the full content of the document.
 */
interface TextDocumentContentChangeEvent {
	/**
	 * The range of the document that changed.
	 */
	range?: Range;

	/**
	 * The length of the range that got replaced.
	 */
	rangeLength?: number;

	/**
	 * The new text of the range/document.
	 */
	text: string;
}

but monaco-languageclient send data to sever like this:

{
    "method": "textDocument/didChange",
    "params": {
         "contentChanges": [
                 {  "text": "{↵    "$schema": "http://json.schemastore.org/coffeelint",↵    "line_endings": "unix"↵}aaa"  }
         ]
     }
}

the difference is in contentChanges.

@akosyakov
Copy link
Contributor

It depends on a language server, the json server used in the example is not able to handle incremental changes, so the client always sends the whole document. A server can communicate it as a part of exchanging initialization capabilities. Look for TextDocumentSyncKind in the specification.

@vincentLiuxiang
Copy link
Author

monaco-languageclient

15

theia-ide

15

@vincentLiuxiang
Copy link
Author

so, if My server support handle incremental changes, I can get the same result like the theia-ide?

what's more could you give an example that is closer to the production environment? java, js and so on?

@vincentLiuxiang
Copy link
Author

@akosyakov I am very new in LSP, I have Look for TextDocumentSyncKind in the specification. Thank you very much!

@akosyakov
Copy link
Contributor

@vincentLiuxiang You are welcome, I am closing it.

@Louis-7
Copy link

Louis-7 commented May 7, 2018

I know this issue has been closed but I saw the screen shot, there is a "Content-Length: 25x" at the beginning of the data return by web-socket which as same as my project which use the language server provide by monaco-languageclient. This "Content-Length" will cause an error at language server side. But I didn't see it in the example given by monaco-languageclient. I'm wondering why I have this "Content-Length" and will it crash the hole process?

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

No branches or pull requests

3 participants