randy3k / radian

A 21 century R console
MIT License
1.96k stars 73 forks source link

Unexpected Alt+Backspace behaviour on Mac #464

Closed sverrirarnors closed 5 months ago

sverrirarnors commented 5 months ago

When Alt+Backspace is pressed in the regular R terminal (at least on Mac), it deletes a whole word. The word boundary is defined by a couple of characters, for example, space, comma, period, equal sign, and every type of bracket.

For example, if I write a function call with arguments function(argument). If I have the cursor after the t in argument and press Alt + Backspace, the regular R terminal deletes everything up to the bracket, with the result being function().

In radian, by contrast, the only character that the Alt + Backspace combo stops on is space. In the example above, I would end up with ) after performing the same action.

randy3k commented 5 months ago

In radian, by contrast, the only character that the Alt + Backspace combo stops on is space. In the example above, I would end up with ) after performing the same action.

On my macOS with iTerm2, radian and R have the same behavior, the word argument is removed. We used prompt-toolkit. A quick check confirms that it is the intended behavior. ref: https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/emacs.py#L75

sverrirarnors commented 5 months ago

You are totally correct. I was comparing radian in VS Code and R in iTerm2. It seems to be a VS Code-specific issue; see this Stackoverflow thread.