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
Completion Suggestions are only available at start of a line. #1510
Comments
@derau2 We can't help you without seeing your code. Is your code in a public repository somewhere? |
@rcjsuen Thank you. I'm working on a scaled down project to reproduce this issue and hope to have it pushed to github by days end. I'll tag you in a comment when it's ready. Thanks for your help. Don |
@rcjsuen here is the project to created this issue. https://github.com/derau2/public If you press CTRL-S at start of line intellisense works. If you type something prior to CTRL-S., such as "test " |
@derau2 I can't
|
@rcjsuen Hopefully it will build for you now. Thanks, |
@derau2 Where does this |
@rcjsuen |
@derau2 I could not find anything obviously wrong with your code. It must be related to how function createProposals() {
return [
{
label: 'foobar1',
kind: monaco.languages.CompletionItemKind.Snippet,
insertText: '{{account-id}}',
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
},
{
label: 'foobar2',
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: '{{account-id}}',
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
},
{
label: 'foobar3',
kind: monaco.languages.CompletionItemKind.Text,
insertText: '{{account-id}}',
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
}
];
}
monaco.languages.register({
'id': 'BosTokensLanguage'
})
monaco.languages.registerCompletionItemProvider('BosTokensLanguage', {
provideCompletionItems: function(model, position) {
var suggestions = createProposals();
return {
suggestions: suggestions
};
}
});
monaco.editor.create(document.getElementById("container"), {
value: "",
language: "BosTokensLanguage"
}); |
@rcjsuen Thanks, I developed it initially in the playground. Thanks for investigating. |
@derau2 Hey there, I was having the same issue on v0.17.0. until I changed // completion-provider.js to be imported
function createProposals (monaco) {
return [{
label: 'html',
kind: monaco.languages.CompletionItemKind.Function,
insertText: '<html>$1</html>',
detail: '<html></html>',
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
}]
}
export const completionItemProvider = (monaco) => {
const suggestions = createProposals(monaco)
return {
provideCompletionItems (model, position) {
return {
suggestions
}
}
}
} into this export const completionItemProvider = (monaco) => {
return {
provideCompletionItems (model, position) {
return {
suggestions: [{
label: 'html',
kind: monaco.languages.CompletionItemKind.Function,
insertText: '<html>$1</html>',
detail: '<html></html>',
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
}]
}
}
}
} // main.js
import { completionItemProvider } from './completion-provider'
import { id } from './config'
monaco.languages.registerCompletionItemProvider(id, completionItemProvider(monaco, id)) and the suggestion was able to be triggered elsewhere. @rcjsuen Any idea why it works this way? |
@DMXL Not sure. It could be the difference between being dynamic or not I suppose. |
Yeah. I think |
@jrieken Can you please confirm? If that is the case, could we please document in JSDoc that we always expect fresh objects to come from |
Thanks @DMXL!! Didn't know why didn't work until I changed my code to recreate objects. |
Hey guys,
|
Well, Never mind...
|
Bro, you saved my days or i should say my life. Whoever reads this, it maybe helpful. Example: export const completionItemProvider = (monaco, measures,AGGREFATE_FUNCTIONS) => {
return {
provideCompletionItems (model, position) {
return {
suggestions: [...AGGREFATE_FUNCTIONS.map(fun => {
return {
label: fun.name,
insertText: fun.syntax,
detail: fun.description,
documentation: fun.description,
kind: monaco.languages.CompletionItemKind.Function,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
}
}),
...measures.map(msr => {
return {
label: msr.name,
insertText: msr.name,
detail: msr.dataSetType,
documentation: msr.dataSetType,
kind: 18
}
})
]
}
}
}
} This will not work :------> (after first line) export const completionItemProvider = (monaco, measures,AGGREFATE_FUNCTIONS) => {
let suggestions = AGGREFATE_FUNCTIONS.map(fun => {
return {
label: fun.name,
insertText: fun.syntax,
detail: fun.description,
documentation: fun.description,
kind: monaco.languages.CompletionItemKind.Function,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
}
})
return {
provideCompletionItems (model, position) {
return {
suggestions: suggestions
}
}
}
} And i don't know why. That's the beauty of Javascript. |
If the issue still persists, please open a new issue. |
monaco-editor version: 2.0.4
Browser: Chrome
OS: Windows 10
Steps or JS usage snippet reproducing the issue:
I register a custom language. I am able to select and complete suggestions by typing CTRL-SPACE. This only seems to work at start of line.
Sequence of events.
Type CTRL-SPACE -> list of suggestions is provided.
Type followed by a space character and then enter CTRL-SPACE --> "No suggestions is displayed
Hopefully the provided GIF will help to illustrate what I'm seeing
The text was updated successfully, but these errors were encountered: