monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

Custom autocompletion ordering / periods in completion items

Open aarinsmith opened this issue 10 years ago • 6 comments

monaco-editor npm version: 0.6.1 Browser: Chrome OS: MAC OSX 10.11.6

I have created a custom language for use with the editor. When registering a completion provider I was curious to know if there is a way of defining a custom sorting algorithm perhaps taking into account the most recent completion items. As an example I have multiple data objects that contain periods. eg. aaa.bbb.ccc aaa.ddd.eee bbb.ccc.ddd bbb.xxx.yyy xxx.yyy.zzz

this ends up being a fairly enormous list with many repeating patterns between the periods. currently it sorts the list alphabetically.

So if I have 100 aaa.bbb.* And 100 xxx.aaa.*

if i type xxx.aaa the autocomplete ends up splitting on the period and listing the first 100 aaa.bbb.* entries. However I would like it to prioritize by the xxx search that preceded it.

Is this something that is possible? And if not. Can someone point me in the direction of the code that is responsible for splitting my autocomplete items on the periods? Customizing this for my current project would not be the most ideal solution but would at least allow proper ordering when typing autocomplete suggestions.

aarinsmith avatar Oct 04 '16 20:10 aarinsmith

@jrieken @joaomoreno should know.

alexdima avatar Oct 06 '16 13:10 alexdima

Thanks, if anyone has any insight into a possible solution it would definitely help. Another thing I am curious about is if there is a way of registering completion providers within another. The list of data objects is huge. Because I am using this on the web it is not always optimal to register all the items at a single time. Does anyone know if it would be possible to have a completion item make an additional call to register its sub items.

For example:

When typing aaa make a subsequent API call to return and register the list of sub entries. aaa.bbb aaa.ccc aaa.ddd

aarinsmith avatar Oct 06 '16 17:10 aarinsmith

@jrieken @joaomoreno do either of you have any suggestions for this? Or happen to know where in the source I may be able to make a custom change for myself that would allow . in autocompletion items? I feel like this would be the simplest solution for my use at this point.

aarinsmith avatar Oct 11 '16 23:10 aarinsmith

Hi @aarinsmith, sorry for the delay.

The splitting on the period issue is Microsoft/vscode#11423 and was recently fixed. It will come with the October release.

There is no notion of sub completion providers. But there are incomplete completion results. You can use this to return only a subset of results initially. Once the user types more, your completion provider will be asked to provide further items.

joaomoreno avatar Oct 14 '16 06:10 joaomoreno

Hey no worries @joaomoreno, thanks for answering. In the mean time I spent a little more time looking over the API. I didn't notice the incomplete completion results feature. I was intending on re-mapping my completion items to a nested dictionary and then using regex matching to provide a way to get subsequent subsections of completion results but maybe this feature could take care of that for me? Do you by any chance know where I could find examples of this in use?

aarinsmith avatar Oct 14 '16 16:10 aarinsmith

You cat set isIncomplete to true and your provider will be asked to provide more items on the next keypress.

joaomoreno avatar Oct 19 '16 21:10 joaomoreno