tth05 / obsidian-completr

Auto-completion plugin for the obsidian editor.
MIT License
291 stars 18 forks source link

Add option to autocomplete while maintaining case first letter #10

Closed JoshKasap closed 2 years ago

JoshKasap commented 2 years ago

If I start typing a word and then use completr to finish that word it overrides the case of the first letter. In most cases I would prefer to maintain the case of the original word I'm typing. image

This is also a problem in that if both upper and lowercase versions of a word are stored in completr and you start typing out the uppercase version the lowercase version will show above it. When both are shown I would expect the one that closest matches the case of the typed word to be displayed first. image Of course, when this is the case it might just be a better idea to merge the displayed options into one and display the suggestion as a single entry in the case that matches what the user typed. (but that's up to you)

I'm sure some people might prefer completr to override text case as it does now so having this be an option that can be changed in the settings would be ideal. However, I would argue the default behavior should be to maintain the case the user provided if possible.

tth05 commented 2 years ago

That looks like you want this: image

JoshKasap commented 2 years ago

Oh yeah, guess I missed that, match case and replace would probably do what I'm thinking. But I just tried it out and for some reason, completr doesn't seem to work at all when I choose that option. No, autocomplete boxes appear at all. I tried refreshing obsidian and re-searching for words but in the end it wouldn't work at all. When I changed it to the other two ignore case options it worked again.

tth05 commented 2 years ago

Seems like it broke when I did some refactoring. Should be working now! Fixed in 18376d38667f977fedd56611b565aa57df581ce8

tth05 commented 2 years ago

@JoshKasap Does this work as expected now?

MatteCrystal commented 2 years ago

Note: This is my other github account, I'm the same person.

Almost but just slightly off. It will match the case if that matching case was stored. Ex: I stored the name Molly so if I start typing it with a capital M I will get the suggestion. image

But if I start typing molly with a lower case m I don't get any suggestions because I've never written molly in all lower case. image

Ideally, I would expect to get the suggestion of molly in both scenarios and the suggestion case would match whether I started with upper or lower case.

So it should match case on the user input side but ignore the case of stored words if that makes sense.

Another example: let's say I had itunes as a stored word and nothing else. Then I typed iTun, the autocomplete suggestion would match what I typed so far to the stored word itunes. But the displayed autocomplete suggestion would not be itunes. It would be iTunes because it matches the case format I already typed and then uses the rest of the stored word to autocomplete the last portion.

tth05 commented 2 years ago

Now that just sounds like exactly what Ignore-Case & Append does, as I mentioned in my first reply.

MatteCrystal commented 2 years ago

ahh ok I was using match case and replace It's a little confusing understanding what each one does.

Anyway, I swapped to Ignore-Case & Append It's basically what I described except for one small issue. It displays the result multiple times.

image

So i have iTunes stored in 3 different ways with different case. Ignore-Case & Append properly maintains the case of what I typed and displays the autocomplete suggestion correctly. But Ideally, it would be able to recognize that the other suggestions are the same and only display one.

tth05 commented 2 years ago

Glad it works now! The duplicate entries should be fixed. https://github.com/tth05/obsidian-completr/commit/cd51c2a63e68196e39a2dfadca1c21158d730298