akinomyoga / ble.sh

Bash Line Editor―a line editor written in pure Bash with syntax highlighting, auto suggestions, vim modes, etc. for Bash interactive sessions.
BSD 3-Clause "New" or "Revised" License
2.33k stars 77 forks source link

vim insert mode: `C-RET` doesn't work for multiline commands #405

Closed 10b14224cc closed 4 months ago

10b14224cc commented 4 months ago

ble version: Bash version:

GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu) [Arch Linux]
ble.sh, version 0.4.0-devel4+27e6309e (noarch) [git 2.43.0, GNU Make 4.4.1, GNU Awk 5.3.0, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)]
starship, version 1.17.1 (rustc 1.75.0 (82e1608df 2023-12-21) (Arch Linux rust 1:1.75.0-1), 2024-01-03 07:54:53 +00:00)
zoxide, version 0.9.2 (/usr/bin/zoxide)
atuin, version 17.2.1 (/usr/bin/atuin)
locale: LANG=en_US.UTF-8 LC_TIME=en_DK.UTF-8
terminal: TERM=xterm-kitty wcwidth=15.0-west/15.1-2+ri, kitty:0 (1;4000;32)
  1. Set up ble.sh to use vim mode
  2. Enter insert mode
  3. Copy-past a multi-line command like this
  4. Press CTRL-RET. The cursor goes on to a new line, a newline is created, but the commands are not run. This is against documented behavior
  5. Press CTRL-j. The commands are correctly executed in their order.
akinomyoga commented 4 months ago

Thanks, indeed I find an inconsistency between the documentation and the actual default binding. I don't remember which one is the one that I originally intended.

I checked the change history. When the vi mode implementation was first introduced, C-RET seems to have meant the history expansion (history-expand-line) (f82cbc4), which inherited the binding in the emacs mode (c68412b). I soon changed it to mean the insertion of a newline (newline) (4b68c1c). I later decided to change it to mean the forcible execution of the command (accept-line) (2bc1a83) in vi_imap together with other keymaps. However, it was reverted to newline in commit 2b20c88, which doesn't seem to be intentional. Also, C-RET in vi_map is inconsistent with other keymaps. I think I should change it back to accept-line.

Thank you for the report. I'll later update the default keybinding of vi_imap.

I'm currently working on other parts of ble.sh, so I'll apply the fix later. Until I push the fix, could you temporarily bind C-RET to the original one in your ~/.blerc?

# blerc

ble-bind -m vi_imap -f C-RET accept-line
10b14224cc commented 4 months ago

Well I can useC-j for the time being :)

akinomyoga commented 4 months ago

I pushed a fix 0b18f3c254d7bc16728f840f94447cff957ecd46. Could you check the behavior?

akinomyoga commented 4 months ago

@10b14224cc Have you checked this? Can I close the issue?

10b14224cc commented 4 months ago

Now RET creates a new line and CTRL-RET execute the whole command

akinomyoga commented 4 months ago

Thanks for the confirmation!