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

Question about location of SnippetString / TypedString #152

Closed
eriklieben opened this issue Jan 29, 2017 · 3 comments
Closed

Question about location of SnippetString / TypedString #152

eriklieben opened this issue Jan 29, 2017 · 3 comments

Comments

@eriklieben
Copy link

Probably related to this change 259a30a

I am a bit stuck/ lost. I have updated my packages from the beta packages to the regular ones, but are unable to get a reference to the SnippetString or TypedString object.

old package.json

    "vscode-languageclient": "^3.0.1-alpha.13",
    "vscode-languageserver": "^3.0.1-alpha.13",
    "vscode-languageserver-types": "^3.0.1-alpha.9",

package.json now

    "vscode-languageclient": "^3.0.3",
    "vscode-languageserver": "^3.0.4",
    "vscode-languageserver-types": "^3.0.3",

When using any of the below lines:

import { TypedString, SnippetString } from 'vscode-languageclient';
import { TypedString, SnippetString } from 'vscode-languageserver';
import { TypedString, SnippetString } from 'vscode-languageserver-types';

All return not found / no exported members warnings.

In the client main.ts, the following works, but that doesn't work from within a language server.

import { SnippetString } from 'vscode';
let x = new SnippetString('foo=$0');

Will this be resolved as soon as v3.0.4 of the vscode-languageserver-types is released?
Or am I doing something wrong? / Is there some sample code available of how to do this correctly?

Thanks in Advance,

Erik

@dbaeumer
Copy link
Member

Based on feedback we changed the way how snippet strings are treated in the protocol. This was breaking but ok from an alpha release to a final version. The underlying reason for this was to keep the protocol compatible to earlier versions.

Since snippet strings occur in completion items the CompletionItem interface now offers

export interface CompletionItem {
	/**
	 * The format of the insert text. The format applies to both the `insertText` property
	 * and the `newText` property of a provided `textEdit`.
	 */
	insertTextFormat?: InsertTextFormat;
}

/**
 * Defines whether the insert text in a completion item should be interpreted as
 * plain text or a snippet.
 */
export namespace InsertTextFormat {
	/**
	 * The primary text to be inserted is treated as a plain string.
	 */
	export const PlainText: 1 = 1;

	/**
	 * 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.
	 *
	 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
	 */
	export const Snippet: 2 = 2;
}

export type InsertTextFormat = 1 | 2;

@octref
Copy link
Contributor

octref commented Feb 3, 2017

@dbaeumer Can you reflect that in README? Because the following is no longer true:

  • New type SnippetText
  • CompletionItem.insertText can now also be a SnippetText.

@dbaeumer
Copy link
Member

dbaeumer commented Feb 6, 2017

Good point. Done.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants