autocomplete
autocomplete copied to clipboard
Recall fetch() after user moves the caret
Hi,
I'm using this autocomplete list to complement words in an input field, not the whole value of the field. It works really well, but a small issue is that if I move the caret to a different word (by either clicking or using the arrow keys), fetch()
will not get called again, and so the autocomplete list content is old, not related to the current word.
Here's an example:
- I have just typed
{{file_
, and the list has correct suggestions: - I move the caret to the first word
{{vault_
by pressing left key. The content of the list stays the same: - This is how the list should look like after moving the caret:
Autocompleter version: 6.1.2
Background for those who are interested: I'm developing a plugin for Obsidian that allows executing shell commands via hotkeys, and the autocomplete feature will be used for complementing certain variable names that my plugin offers. I haven't yet released a version that contains this autocomplete feature, but here is a link to a discussion which contains more screenshots: https://github.com/Taitava/obsidian-shellcommands/discussions/32#discussioncomment-1706632
Thank you for your support, and for this awesome library! 🙂
Hi Taitava,
Please try the latest version on GitHub. It should allow you to use the widget with separate words.
Here is a sample:
https://jsbin.com/xibaxevuyu/edit?html,js,output
Thanks! I'm not very experienced with npm
. Is there a way to install the latest version from GitHub using npm
? (When doing PHP projects, I know that composer
packages can be installed from e.g. GitHub, but I'm not sure about npm
). I can of course just download manually from GitHub, but I don't feel good for including 3rd party code in my own repository. Well, one option would also be using Git's submodule
feature.
Is the newest version on GitHub considered stable and production ready? Will there be a new npm
release in the future? Thanks again! 🙂
Edit: Plus if I'm gonna use the latest from GitHub, I need to record somewhere the commit id, so that I will later remember which version I'm using. If a release is coming, I might wait for that. 🙂
You can use the following command to install the package from GitHub:
npm install --save-dev https://github.com/kraaden/autocomplete/tarball/master/1590fe09d347f7b6cb1466add5d8e5652bf9d1fb
I tested this now, and got the left and right key working, so pressing them updates the list. I copied this particular configuration line from the demo link you provided to my configuration:
keysToIgnore: [ 38 /* Up */, 13 /* Enter */, 27 /* Esc */, 16 /* Shift */, 17 /* Ctrl */, 18 /* Alt */, 20 /* CapsLock */, 91 /* WindowsKey */, 9 /* Tab */ ]
(Just for the record for others: When keysToIgnore
is defined, it actually unignores left and right keys, because they are not present in the list.)
However, moving the caret to a different word by clicking with mouse does not update the list. So may I ask for this mouse feature to be added, please? 🙂
Anyway, being able to make the left and right keys to update the list, is already an improvement! Thank you for it! 🌞
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
moving the caret to a different word by clicking with mouse does not update the list. So may I ask for this mouse feature to be added, please? 🙂
I'd still like to have this. 🙂
@Taitava It is now possible to trigger autocomplete with a mouse click as shown below:
https://jsbin.com/cuyamokeki/edit?html,js,output
This change is not on NPM yet.
Thank you @kraaden! ❤️