tadashi-aikawa / obsidian-various-complements-plugin

This plugin for Obsidian enables you complete words like the auto-completion of IDE.
MIT License
577 stars 21 forks source link

Feature Request: Two-Step Completions #156

Closed chrisgrieser closed 1 year ago

chrisgrieser commented 2 years ago

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:

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:

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".

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.

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.

tadashi-aikawa commented 2 years ago

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.

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

In addition, the following issue may also help.

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

chrisgrieser commented 2 years ago

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

tadashi-aikawa commented 1 year ago

@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.

chrisgrieser commented 1 year ago

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 🤔

tadashi-aikawa commented 1 year ago

Thank you for your trying :)

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

I agree 👍

Drakemoor commented 1 year ago

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.

tadashi-aikawa commented 1 year ago

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

tadashi-aikawa commented 1 year ago

After #245

tadashi-aikawa commented 1 year ago

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

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

vanbang9710 commented 11 months ago

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

tadashi-aikawa commented 11 months ago

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

vanbang9710 commented 11 months ago

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

tadashi-aikawa commented 11 months ago

@vanbang9710 Please read this issue.

vanbang9710 commented 11 months ago

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

tadashi-aikawa commented 11 months ago

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.

vanbang9710 commented 11 months ago

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

tadashi-aikawa commented 11 months ago

@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?

vanbang9710 commented 11 months ago

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

asknet commented 6 months ago

@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!

tadashi-aikawa commented 6 months ago

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

image

asknet commented 6 months ago

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