tth05 / obsidian-completr

Auto-completion plugin for the obsidian editor.
MIT License
291 stars 18 forks source link

Suggestion: Suggestions should be sorted based on locale #81

Open mocsa opened 6 months ago

mocsa commented 6 months ago

I suggest that the File Scanner Provider and the Word List Provider sorts its results based on a pre-set international locale.

Looking at the code, it seems both providers use dictionary_provider.ts. At the end of the getSuggestions() method it does this:

return result.sort((a, b) => a.displayName.length - b.displayName.length);

I suggest it does something like this, instead:

const mycollator = new Intl.Collator('de');
return result.sort((a, b) => mycollator.compare(a.displayName, b.displayName));

I think there should be a new configuration option where the user can specify the locale. I'm not sure if it is possible to obtain the current locale of Obsidian in JS, but even if it is, it would be better to make this selectable by the user. It is possible, that the user uses Obsidian in English but writes his/her notes in a different language.