Taitava / obsidian-shellcommands

Execute system commands via hotkeys or command palette in Obsidian (https://obsidian.md). Some automated events are also supported, and execution via URI links.
GNU General Public License v3.0
348 stars 11 forks source link

Autocomplete: sort items more intelligently #249

Closed Taitava closed 2 years ago

Taitava commented 2 years ago

Discussed in https://github.com/Taitava/obsidian-shellcommands/discussions/248

Originally posted by **Taitava** July 25, 2022 - If the search term is at least a couple of characters long (excluding a possible `{{`/`{{!` beginning), compare lengths. A shorter item is preferred, because the shorter the item is, the closer it matches to the search term. - Boost: If an item starts with the same characters as the search query starts, boost the item even if it's length is longer. For example, I ahve two custom variables in my test vault: `{{_field_using_variables}}` and `{{_optional_field}}`. If I type `{{_field`, I'd like `{{_field_using_variables}}` to become first, but if the sorting would only take length into account, `{{_optional_field}}` would win. I want the algorithm to pay more attention to items whose beginning matches the search term, and leave behind items who match the search term by their rear part. - If the search term (excluding a possible `{{`/`{{!` beginning) is not at least two characters long, use alphabetical ordering. Alphabetical ordering is also used if the boost weighted lengths are equal, but that's just a nyance.