-
Notifications
You must be signed in to change notification settings - Fork 99
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
RegisterCompletionItemProvider problem #138
Comments
I have no idea also, but it seems you have to do something like this: await Global.RegisterCompletionItemProvider(JsRuntime, "sql", (model, position, context) =>
{
ArgumentNullException.ThrowIfNull(_editor);
var text = _editor.GetModel().Result;
var pos = _editor.GetPosition().Result;
var word = text.GetWordUntilPosition(pos).Result.Word;
if (word is not null &&
word.Trim().EndsWith("FROM", StringComparison.InvariantCultureIgnoreCase))
{
// return your list
}
} In blazor this doesn't work because you can't call |
In await BlazorMonaco.Languages.Global.RegisterCompletionItemProvider(jsRuntime, "javascript", async (modelUri, position, context) =>
{
var model = await BlazorMonaco.Editor.Global.GetModel(jsRuntime, modelUri);
var word = await model.GetWordUntilPosition(position);
var range = new BlazorMonaco.Range
{
StartLineNumber = position.LineNumber,
EndLineNumber = position.LineNumber,
StartColumn = word.StartColumn,
EndColumn = word.EndColumn,
};
return new CompletionList
{
Suggestions = createDependencyProposals(range)
};
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for the port It's awesome.
I want to get the code selection from the provideCompletionItems delegate, like the javascript example on the Monaco playground:
But the wrapper sends a "modelUri" not the model itself, how can I convert this string to the real object? I tried using
BlazorMonaco.Editor.Global.GetModel(JsRuntime, modelUri); or also _editor.GetSelection() but there are not allowed async operations.
Thanks!
The text was updated successfully, but these errors were encountered: