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

Playground - completion-provider-example is missing 'range' property #1352

Closed
oldrich-s opened this issue Mar 8, 2019 · 2 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug documentation
Milestone

Comments

@oldrich-s
Copy link

I see that:

CompletionItem.range is now mandatory. Most times, you can use model.getWordUntilPosition() to get a good range.

I have no idea how to use the model.getWordUntilPosition() so I thought I would find it in the playground example:

https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-completion-provider-example

but it looks like the example was not updated yet.

@oldrich-s oldrich-s changed the title Monaco playground - completion-provider-example is missing range property Playground - completion-provider-example is missing 'range' property Mar 8, 2019
@spahnke
Copy link
Contributor

spahnke commented Mar 8, 2019

so I thought I would find it in the playground example

That's what I hoped as well. Anyway, after a little experimentation I came up with the code below which seems to work for my use cases. I don't know if there is a better/more correct way to do that though.

provideCompletionItems: (model: monaco.editor.ITextModel, position: monaco.Position, context: monaco.languages.CompletionContext, token: monaco.CancellationToken) => {
	const word = model.getWordUntilPosition(position);
	const range: monaco.IRange = {
		startLineNumber: position.lineNumber,
		endLineNumber: position.lineNumber,
		startColumn: word.startColumn,
		endColumn: word.endColumn
	};
	...
}

Hope it helps!

@iknityanand
Copy link

@spahnke It worked! thanks a ton!.

@alexdima alexdima added this to the December 2019 milestone Dec 12, 2019
@alexdima alexdima added bug Issue identified by VS Code Team member as probable bug documentation labels Dec 12, 2019
@alexdima alexdima self-assigned this Dec 13, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug documentation
Projects
None yet
Development

No branches or pull requests

4 participants