Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 518664

Summary: [lsp] DidChangeTextDocumentParams are sent back with incomplete parameters
Product: [ECD] Orion Reporter: Remy Suen <remy.suen>
Component: ClientAssignee: Remy Suen <remy.suen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: unspecified   
Target Milestone: 16.0   
Hardware: All   
OS: All   
Whiteboard:

Description Remy Suen CLA 2017-06-22 16:48:57 EDT
The 'textDocument/didChange' notification provides range-based TextDocumentContentChangeEvents if the server requests an incremental synchronization method for the documents.

/**
 * 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;
}

Currently, the code does not define the 'range' parameter correctly as it always sets a 'range' that has identical 'start' and 'end' positions. Its 'rangeLength' parameter however is correct so servers could technically get by.

https://github.com/eclipse/orion.client/blob/83ed03ca018d6f83c94fbc789fb850d9f4bfd3fd/bundles/org.eclipse.orion.client.ui/web/orion/editorView.js#L399-L403

https://github.com/Microsoft/language-server-protocol/issues/9
https://github.com/Microsoft/language-server-protocol/issues/53

Due to the ambiguity in the protocol, we should not rely on the server to correctly discard the 'range.end' value if 'rangeLength' is defined. A language server may instead choose to discard 'rangeLength' because 'range.end' has been defined.