darlal/obsidian-switcher-plus

Press number keys 1,2,3,..,9 to select items

maggaou opened this issue · 2 comments

For example in Bookmarks mode one could press 2 to directly open the second item in the list. Obviously when this feature is enabled, one cannot perform filtered search if the query includes numbers (see details below).

Other special cases:
If numbers are used in toggle symbols for different modes, prioritize this behavior.

If filtered search is used, select these results using numbers 1,2,3,..,9 (OR) If filtered search is used, then this feature is disabled.

If restore previous input is on, it should work similarly as doing filtered search and then pressing number to select item.

In addition display number icons (possibly using different color than list items) next to list items to indicate the feature (or to indicate that the feature is on, if not enabled by default).

darlal commented

Thanks for the feature request. If I understand correctly the feature is to enable selection of items 1-9 in the result list using a hotkey, you're proposing number keys 1-9. Let me know if I've miss understood the request.

As you've pointed out, using these hotkeys by themselves will interfere with regular typing. One way to work around this is to use a modifier key, so for example cmd/ctrl modifier plus the number key.

If numbers are used in toggle symbols for different modes, prioritize this behavior.
f filtered search is used, select these results using numbers 1,2,3,..,9 (OR) If filtered search is used, then this feature is disabled.

Both of these become non-issues with modifier key plus number key.

If restore previous input is on, it should work similarly as doing filtered search and then pressing number to select item.

I'm not sure follow this one. Do you mean it should behave the same way as you described above in the "filtered search" paragraph, or do you mean the switcher should auto-select the previous selection again, which could be very confusing.

As you've pointed out, using these hotkeys by themselves will interfere with regular typing. One way to work around this is to use a modifier key, so for example cmd/ctrl modifier plus the number key.

The problem with cmd + 1 might be that it doesn't override other command that already has this shortcut. If possible in the API, cmd + 1 (etc) should override any existing shortcuts.

When using numbers as toggle symbols, the problem only arises when we are in standard mode and current input box is empty OR in standard mode and current input box has exactly parts of a toggle symbol. For instance when using m1 as bookmarks mode then writing 1 after m should not trigger item selection. I think using numbers for different modes can be productive and useful since you can then avoid having different keyboard shortcuts for different modes and you can use these same keyboard shortcuts for something more productive. I'm not sure if m1 is useful as toggle symbol, so we could forbid using numbers at the end of a toggle symbol to make the above coding easier.

About using filtered search: yes it's useful to being able to select these items using cmd + 1 etc. But using filtered search is much less frequent action than selecting pre-displayed items in the list. So we could easily disable item selection using numbers when filtered search occurs, and then use item selection with numbers otherwise. There is one special case: when filtered search should start with number. But I think this is rare use case.

I mean the difference is day and night to type 6 compared to cmd + 6. Even typing 1 compared cmd + 1 is faster, easier and more convenient.

I'm not sure follow this one. Do you mean it should behave the same way as you described above in the "filtered search" paragraph, or do you mean the switcher should auto-select the previous selection again, which could be very confusing.

Yes I didn't mean the switcher should auto-select the previous selection again.