dendronhq / dendron

The personal knowledge management (PKM) tool that grows as you do!
https://wiki.dendron.so
Apache License 2.0
6.74k stars 257 forks source link

Allow override of lookup sorting results. #2504

Open nickolay-kondratyev opened 2 years ago

nickolay-kondratyev commented 2 years ago

Please select if your request is either something new or an enhancement

Please select the area your request applies to. (Multiple selections are Possible. You can leave blank if you're not sure.)

Is your feature request related to a problem? Please describe

Current look up sorting favors levenshtein distance in favor of last update date. Which makes shorter results bubble up to the top even if those notes haven't been touched in a long time. For many use cases this is the right behavior but also often there are other lookups when we want a different sort order of lookup result to take precedence. For example when looking for recently edited file.

Example: Looking up meeting note we would want to have the most recently edited meeting note bubble up, instead of shortest meeting note.

Describe the solution you'd like

Add optional argument to look up command to override default sort ordering.

Possible implementation:

Which can allow users to customize their lookup commands for different use cases:

 {
    "key": "{desired keybinding}",
    "command": "dendron.lookupNote",
    "args": {
      "lookupOrder": ["itemScore", "isStub", "levenshteinDist", "updatedTime" ]
    }
  }
 {
    "key": "{desired keybinding}",
    "command": "dendron.lookupNote",
    "args": {
      "lookupOrder": ["itemScore", "isStub",  "updatedTime" , "levenshteinDist",]
    }
  }

Describe alternatives you've considered

jonathanyeung commented 2 years ago

I like this idea of being able to easily modify the sort order directly within the lookup experience (either via keybinding, button, keyword, or something else), and I think it'd make lookup much more powerful.

We were just discussing internally about potential ways of how Lookup can be if we were to design it from first-principles, and I was also thinking about dynamically controlled sort-order.

No guarantees on delivery date, but hopefully you won't need to hand edit your extension.js for too long :)

aleksey-rowan commented 2 years ago

Linking a related issue:

It suggests a UI toggle in the quickpick component to modify the sorting order.

aleksey-rowan commented 2 years ago

instead of shortest meeting note.

Did you mean "shortest" as in the amount of text in the note? In either case, I think it would make a great ordering ordering option to sort results by their word count. I think Implement Text Statistics (aka 'word count') needs to be done first though.

nickolay-kondratyev commented 2 years ago

@aleksey-rowan In this case no I meant actually shortest length of the note name. If two notes have the same fuseJS matching score but one of those notes has a shorter name it will show up higher in the sorting results.

As example lets say we search for meetin

And our notes are meeting.made-in-1990 and meeting.created-yesterday-in-2022

meeting.made-in-1990 will show up on top of the meeting.created-yesterday-in-2022. Since it will have a closer levenshteinDistance to meetin than meeting.created-yesterday-in-2022
Code: https://github.com/dendronhq/dendron/blob/master/packages/common-all/src/fuse.ts#L332