val-town / codemirror-codeium

Codeium code completion integration for CodeMirror 6
https://val-town.github.io/codemirror-codeium/
Other
52 stars 4 forks source link

Accept suggestions on mobile #7

Open hatemhosny opened 7 months ago

hatemhosny commented 7 months ago

Great project 👍 Thank you for open-sourcing this.

CodeMirror6 has great mobile support. I use it in LiveCodes (a client-side code playground for 80+ languages/frameworks) as the default editor on mobile.

Currently accepting suggestions requires hitting the tab button which is not available by default on mobile keyboards. Would you consider adding additional key binding for accepting suggestions? May be "Enter" key.

tmcw commented 7 months ago

Yeah, good point - there should be a solution to this. Enter seems reasonable, but I'm not sure about adding Enter as a shortcut on desktop - it feels like there are situations where you're at

// Write a factorial function<cursor>

Where you want to hit Enter, but not accept a suggestion below.

stevekrouse commented 7 months ago

I would expect that clicking on the suggestion would accept it on mobile

tmcw commented 7 months ago

Yeah - that'll be somewhat harder to implement with the strategy in this plugin, but it's an option.

hatemhosny commented 7 months ago

Yeah, good point - there should be a solution to this. Enter seems reasonable, but I'm not sure about adding Enter as a shortcut on desktop - it feels like there are situations where you're at

// Write a factorial function<cursor>

Where you want to hit Enter, but not accept a suggestion below.

I agree. On desktop we should stick to "tab" and not "Enter".

The other question is how to reject suggestions without "Esc" button. May be continue typing (not ideal) or click outside (as opposed to click on suggestion to accept). But then what happens to the cursor position?

hatemhosny commented 7 months ago

Another suggestion for rejecting suggestions on mobile is timing out. e.g. if a suggestion was not accepted for e.g. 2 seconds, then it would disappear. Again, this behavior would only be on mobile.

hatemhosny commented 7 months ago

I would expect that clicking on the suggestion would accept it on mobile

Clicking on the suggestion now works very well (#12). Also clicking outside (with the mouse) rejects suggestions. Thank you.

However, I'm having trouble rejecting suggestions on touch screens. When I touch outside suggestion it is still accepted. The only way I can reject suggestion now is continue typing (sometimes this even doesn't reject and continue displacing the suggested text). I have tried that on android phone and windows with touch screen.

Great work indeed. I just thought it would be useful to report that.