autocomplete icon indicating copy to clipboard operation
autocomplete copied to clipboard

Recall fetch() after user moves the caret

Open Taitava opened this issue 3 years ago • 4 comments

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:

  1. I have just typed {{file_, and the list has correct suggestions: kuva
  2. I move the caret to the first word {{vault_ by pressing left key. The content of the list stays the same: kuva
  3. This is how the list should look like after moving the caret: kuva

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

Taitava avatar Nov 28 '21 11:11 Taitava

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

mYrcsjVVU5

denis-taran avatar Nov 28 '21 16:11 denis-taran

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

Taitava avatar Nov 29 '21 12:11 Taitava

You can use the following command to install the package from GitHub:

npm install --save-dev https://github.com/kraaden/autocomplete/tarball/master/1590fe09d347f7b6cb1466add5d8e5652bf9d1fb

denis-taran avatar Nov 30 '21 08:11 denis-taran

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

Taitava avatar Dec 05 '21 09:12 Taitava

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.

stale[bot] avatar Dec 03 '22 04:12 stale[bot]

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 avatar Dec 03 '22 06:12 Taitava

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

denis-taran avatar Feb 07 '23 01:02 denis-taran

Now you can install it via NPM by using the following command:

npm install [email protected]

denis-taran avatar Feb 07 '23 01:02 denis-taran

Thank you @kraaden! ❤️

Taitava avatar Feb 08 '23 18:02 Taitava