redhat-developer / redhat-developer/yaml-language-server

Server returns snippets even though client doesn't support them

Open
#161 3 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
1.5k
Forks
352
Avg merge
2d 7h
Merged PRs (30d)
11

Description

The completion request always returns snippet-type completions, even if the client initialisation request doesn't claim to support them.

Logs:

  • Initialize does not include snippetSupport: true which should be interpreted as not supporting snippets (only plaintext)
2019-07-05 22:43:11,807 - DEBUG - TX: Sending message: b'Content-Length: 654\r\n\r\n{"id": "1", "jsonrpc": "2.0", "method": "initialize", "params": {"capabilities": {"textDocument": {"completion": {"completionItemKind": {"valueSet": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}, "hover": {"contentFormat": ["plaintext", "markdown"]}, "signatureHelp": {"signatureInformation": {"documentationFormat": ["plaintext", "markdown"], "parameterInformation": {"labelOffsetSupport": false}}}}}, "initializationOptions": {}, "processId": 59070, "rootPath": "/Users/ben/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd", "rootUri": "file:///Users/ben/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd"}}'
  • completion request
2019-07-05 22:46:30,803 - DEBUG - TX: Sending message: b'Content-Length: 215\r\n\r\n{"id": "4", "jsonrpc": "2.0", "method": "textDocument/completion", "params": {"position": {"character": 2, "line": 0}, "textDocument": {"uri": "file:///Users/ben/Development/lsp/yaml/tests/ansible/tasks/main.yml"}}}'
  • response (snipped)
2019-07-05 22:46:30,828 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":"4","result":{"items":[{"kind":10,"label":"shell","insertText":"shell: $1","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":0,"character":2},"end":{"line":0,"character":4}},"newText":"shell: $1"}},

Note: "insertTextFormat":2 is 'snippet' :

	/**
	 * The primary text to be inserted is treated as a snippet.
	 *
	 * A snippet can define tab stops and placeholders with `$1`, `$2`
	 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
	 * the end of the snippet. Placeholders with equal identifiers are linked,
	 * that is typing in one will update others too.
	 */
	export const Snippet = 2;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how initialization capabilities and completion responses are handled in the TypeScript language server. Verify the behavior against the logged initialize and textDocument/completion requests; done means clients without snippetSupport receive plaintext-compatible completions rather than insertTextFormat 2.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.