codemirror-codeium icon indicating copy to clipboard operation
codemirror-codeium copied to clipboard

Accept suggestions on mobile

Open hatemhosny opened this issue 1 year ago • 6 comments

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.

hatemhosny avatar Mar 26 '24 03:03 hatemhosny

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.

tmcw avatar Mar 26 '24 12:03 tmcw

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

stevekrouse avatar Mar 26 '24 12:03 stevekrouse

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

tmcw avatar Mar 26 '24 13:03 tmcw

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 avatar Mar 26 '24 13:03 hatemhosny

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 avatar Mar 26 '24 13:03 hatemhosny

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.

hatemhosny avatar Mar 31 '24 12:03 hatemhosny