obsidian-various-complements-plugin icon indicating copy to clipboard operation
obsidian-various-complements-plugin copied to clipboard

Feature Request: Two-Step Completions

Open chrisgrieser opened this issue 3 years ago • 2 comments
trafficstars

The Problem After accumulating more words in my custom dictionaries, I noticed a lot of completions actually share a similar "string beginning". For example I have quite a bunch of completions that look like this: Pasted image 2022-07-24 23 34 01

The problem here is that I would have to scroll through quite the list if I wanted to select "innovation studies". Narrowing down the list by typing more letters also is quite inefficient, since I would have to type out "innovation s" reduce the number of completions sufficiently. However, both methods would defeat the purpose of an autocompletion mechanism, since the very idea of of autocompletion is to reduce the amount of typing.

I think the problem is specific to autocompletion of natural languages, since conjugations or plural forms result in words with a similar stem ("organize", "organizing", "organization", ...)


A Suggestion for a Solution I think the best solution to tackle this would be some sort of "two-step-completion". If Various Complements notices that there are many items that have the same beginning, then it should (partially) merge the items into a new item that is consists of the shared string beginning. Selecting that item would complement that partial string, and instantly trigger a second, follow-up suggester, displaying the remaining string of the previously merged items. Let me illustrate with an example. Suppose you have a custom dictionary with the following terms:

  • organize
  • orchestra
  • organizing
  • organizers
  • organizer
  • organization
  • organizations

Typing "or" would give you seven suggestions, a lot to scroll through if you want to select "organizations". But as six of the items share a string beginning – "organiz" – the suggester could summarize and display two items:

  • organiz...
  • orchestra

Now, if I select "orchestra", various complements would work as usual. However, if I select "organiz...", Various complements would complement "organiz" and then display a follow-up suggester, displaying these items, which are the "remaining" strings of the items from above, if you cut "organiz".

  • e
  • ing
  • ers
  • er
  • ation
  • ations

Now, I could type "a" to reduce the list to two items, and then easily select one of them.


Evaluation of the Suggested Solution Now we can compare the different approaches to see how the suggestion would improve the autocompletion mechanism. Suppose we want to select "organizations" from our list of seven items from above.

  • Method 1: type or, hit arrow down six times, hit enter → 9 keystrokes
  • Method 2: typing till you have reduced the list to two items: organiza, then hit arrow down one time, hit enter → 10 keystrokes
  • Method 3 (the suggested solution): type or, hit enter to select "organiz...", type a. You now have "ation" and "ations" left, and press arrow down and enter to select right word. → 5 keystrokes

That's a reduction of keystrokes by ~50%. And that does not even factor in the fact that the suggested solution also reduces the amount of text your eyes see (the redundant "organiz" is only displayed once, not six times), which probably also makes the "scanning" for the right item quicker. And on top of that, this is even a fairly simple example. In cases like with the screenshot above (all the words starting with "innovat"), the words are longer and there are more items; meaning you would save even more keystrokes in cases like that.

Implementing this feature request would make Various Complements reflect the characteristics of natural languages, instead of simply applying the autocompletion-logic from code editors without considering that text is different from code. This would make Various complements a truly smart completion engine – one that I even do not know in any other app.

chrisgrieser avatar Jul 24 '22 22:07 chrisgrieser

Hi, @chrisgrieser. Thank you for your FR :)

Your suggestion is very amazing, but it would be too hard to implement it for now.

As an alternative, how about a terminal-like feature that completes up to common forward matching characters?

For example.

  • organize
  • orchestra
  • organizing
  • organizers
  • organizer
  • organization
  • organizations

If we push org<TAB> , it completes to organiz and shows suggestions as follows.

  • organize
  • organizing
  • organizers
  • organizer
  • organization
  • organizations

In addition, the following issue may also help.

https://github.com/tadashi-aikawa/obsidian-various-complements-plugin/issues/141

tadashi-aikawa avatar Jul 31 '22 03:07 tadashi-aikawa

As an alternative, how about a terminal-like feature that completes up to common forward matching characters?

that sounds like a very good alternative solution, yes! Potentially even better than mine, cause users familiar with the Terminal (to which I also belong) may find this more intuitive

chrisgrieser avatar Jul 31 '22 09:07 chrisgrieser

@chrisgrieser I have released v7.4.0-beta1 🚀

Please enable the following option and try it 👍

image

I have been using this feature for a while and personally I am not sure if it is really necessary. So I marked this feature as Experimental.

tadashi-aikawa avatar Nov 09 '22 01:11 tadashi-aikawa

Thanks, I just tried it and works so far. I'll keep you posted how well it works on daily usage.

One thing I already noticed is that it kinda interferes with tab as additional cycle key, and tab-cycling is the standard in the Terminal or in code editors, so it might be useful to have alternatives keys for common prefix completion. But I'm also not sure about this one 🤔

chrisgrieser avatar Nov 09 '22 12:11 chrisgrieser

Thank you for your trying :)

it might be useful to have alternatives keys for common prefix completion

I agree 👍

tadashi-aikawa avatar Nov 13 '22 07:11 tadashi-aikawa

Hi, I'm a bit late to the discussion, but how about something like this: image

Where you can press the corresponding number to select the word you need. The screenshot is from Fastkeys, which also has autosuggest, but the problem with it is it doesn't show the suggestions under the caret and doesn't have all the other goodies Various Complements has.

Drakemoor avatar Jun 28 '23 18:06 Drakemoor

@Drakemoor Please follow the https://github.com/tadashi-aikawa/obsidian-various-complements-plugin/issues/141 👍

tadashi-aikawa avatar Jul 01 '23 04:07 tadashi-aikawa

After #245

tadashi-aikawa avatar Aug 22 '23 09:08 tadashi-aikawa

@chrisgrieser I have released it in v9.0.0-beta1 🚀

I would appreciate it if you could check it out before the official release.

tadashi-aikawa avatar Aug 26 '23 08:08 tadashi-aikawa

I currently can't discern the hotkey "completion" with simply pressing Esc

vanbang9710 avatar Sep 26 '23 10:09 vanbang9710

@vanbang9710 I do not recommend assigning Escape, but if necessary, create an Issue.

tadashi-aikawa avatar Sep 27 '23 05:09 tadashi-aikawa

I meant I don't know what the hotkey "completion" is for. It seems the same as Esc

vanbang9710 avatar Sep 28 '23 00:09 vanbang9710

@vanbang9710 Please read this issue.

tadashi-aikawa avatar Sep 28 '23 01:09 tadashi-aikawa

I've already read it before asking. Can you please explain further?

vanbang9710 avatar Sep 30 '23 02:09 vanbang9710

I meant I don't know what the hotkey "completion" is for. It seems the same as Esc

The "completion" command runs "Two-Step Completions".

chrisgrieser already explains why such a completion is needed as https://github.com/tadashi-aikawa/obsidian-various-complements-plugin/issues/156#issue-1316022345. Then, I implemented that feature link https://github.com/tadashi-aikawa/obsidian-various-complements-plugin/issues/156#issuecomment-1200340717.

If you are unclear about any of those comments, please quote them and ask questions.

tadashi-aikawa avatar Sep 30 '23 04:09 tadashi-aikawa

When I press "Completion", the models is closed and the word stays the same |50pct

vanbang9710 avatar Sep 30 '23 10:09 vanbang9710

@vanbang9710

the word stays the same

It is as expected because all suggestions start with machine. For details, please read https://github.com/tadashi-aikawa/obsidian-various-complements-plugin/issues/156#issuecomment-1200340717.

the models is closed

It is not as expected. And I couldn't reproduce it. Could you tell me the reproduction steps in the sandbox vault?

tadashi-aikawa avatar Oct 01 '23 08:10 tadashi-aikawa

I understand how it works now. Sorry, the unexpected behavior was because I used an assigned hotkey

vanbang9710 avatar Oct 02 '23 04:10 vanbang9710

@tadashi-aikawa Thank you for the wonderful plugin and apology for adding a comment on a closed ticket. Want to add here to keep the context. My question is:

I tried tab-based completion (like in the terminal), but the tab key works differently in obsidian. How do I utilize this feature? Thanks!

asknet avatar Feb 15 '24 02:02 asknet

@asknet The ⚙️ Hotkeys configuration should work for you.

image

tadashi-aikawa avatar Feb 17 '24 04:02 tadashi-aikawa

Thank you @tadashi-aikawa. Appreciate the quick response!

asknet avatar Feb 19 '24 17:02 asknet