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

Some completion items do not have insertText #540

Open
mjshashank opened this issue Feb 5, 2018 · 2 comments
Open

Some completion items do not have insertText #540

mjshashank opened this issue Feb 5, 2018 · 2 comments

Comments

@mjshashank
Copy link

mjshashank commented Feb 5, 2018

I have been trying to integrate this project as an LSP server for an editor. I've noticed that some of the completions do not have an insertText field.
Eg:
1.

{ label: 'import',
kind: 14,
sortText: '999999213',
data: [Object] }
{ label: 'java.io',
kind: 9,
sortText: '999999215',
 data: [Object] }

How is this expected to be handled with respect to the value to be inserted?

Because inserting the label would mean a lot of redundant characters are being inserted (like in example 2, where after inserting label the code in the editor would become java.java.io instead of java.io).

@puremourning
Copy link
Contributor

puremourning commented Feb 5, 2018

Well, it's a pain. First, insertText is optional, and deprecated, and falls back to label:

	/**
	 * A string that should be inserted into a document when selecting
	 * this completion. When `falsy` the label is used.
	 * 
	 * The `insertText` is subject to interpretation by the client side.
	 * Some tools might not take the string literally. For example
	 * VS Code when code complete is requested in this example `con<cursor position>`
	 * and a completion item with an `insertText` of `console` is provided it
	 * will only insert `sole`. Therefore it is recommended to use `textEdit` instead
	 * since it avoids additional client side interpretation.
	 *
	 * @deprecated Use textEdit instead.
	 */
	insertText?: string;

In order to get the textEdit you have to use the resolve request.

Depending on your editor, this may be difficult. As you can see VSCode actually does a text overlap check on the inserted label.

It wasn't a lot of fun adding this to YouCompleteMe.

@puremourning
Copy link
Contributor

See also:

#465
#353

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

No branches or pull requests

4 participants