Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mode and position off after Atuin history recall with tab #547

Open
miltieIV2 opened this issue Jan 3, 2025 · 5 comments
Open

Mode and position off after Atuin history recall with tab #547

miltieIV2 opened this issue Jan 3, 2025 · 5 comments

Comments

@miltieIV2
Copy link

$ ble version
ble.sh, version 0.4.0-nightly+31f264a (noarch)

~/.blerc

#bleopt keymap_vi_mode_string_nmap=$'\e[1m-- NORMAL --\e[m'

bleopt prompt_ps1_final='$(starship module character)'
bleopt prompt_rps1_final='$(starship module time)'
bleopt indent_offset=2
#ble-bind -m 'vi_imap' -f 'C-c' 'vi_imap/normal-mode-without-insert-leave'
ble-bind -m vi_imap -f 'C-c' discard-line
ble-bind -m vi_nmap -f 'C-c' discard-line

# https://github.com/akinomyoga/ble.sh/issues/537
bleopt history_default_point=begin
  1. Use vi mode.
  2. Enter atuin search.
  3. Select an item from the history.
  4. Hit to recall (not accept) the line to ble.sh.
  5. Observe that: the line is recalled, the cursor is one space past the end of the line, INSERT mode is off - for INSERT mode to be off, the cursor should be on the last character, not past the last character.
  6. Press - the cursor moves to where it should be (on the last character).
  7. It is behaving as if the line was recalled and "A" was pressed (append to end of line), but ble.sh is not in INSERT mode.
  8. Always typing "A" or "a" after tab recall puts ble.sh in the expected mode and position.

(@akinomyoga Not sure if this is related to changes performed in #537)

@miltieIV2
Copy link
Author

It seems like this recall behavior should follow the history_default_point behavior.
This is what BASH "/ does - recall history with cursor at the beginning, in command mode.

@akinomyoga
Copy link
Owner

akinomyoga commented Jan 4, 2025

Thanks for the report. OK, I'll fix it. I was expecting the plugins such as Atuin to properly place the cursor position based on the current mode, but Atuin seems to try to put the cursor at the end of the string. However, Readline seems to automatically adjust the cursor position when a plugin places the cursor at an unallowed position. ble.sh can follow the Readline behavior.

It seems like this recall behavior should follow the history_default_point behavior. This is what BASH "/ does - recall history with cursor at the beginning, in command mode.

Atuin's selection of the history entry is unrelated to the history movement in the line editor. Atuin picks up the command from its own database and inserts the string into the line editor. From the line-editor side (such as Readline and ble.sh), there is no way to tell whether a string inserted by a random plugin would be considered the history movement. If you want to change the cursor position that Atuin sets, you should find or request the corresponding setting in Atuin.

Also, this behavior seems to be the same in plain Bash plus Atuin. Even without ble.sh, the cursor position after the insertion by Atuin is at the end of the text. It's unrelated to ble.sh.

@akinomyoga
Copy link
Owner

akinomyoga commented Jan 4, 2025

Atuin doesn't seem to support the option for the cursor position. It's hardcoded to be at the end of the string. Issue atuinsh/atuin#893 discusses a related extension.

@miltieIV2
Copy link
Author

Thanks!
I obviously don't have a good understand of which parts are doing what.

@akinomyoga
Copy link
Owner

Thanks for the report. OK, I'll fix it. I was expecting the plugins such as Atuin to properly place the cursor position based on the current mode, but Atuin seems to try to put the cursor at the end of the string. However, Readline seems to automatically adjust the cursor position when a plugin places the cursor at an unallowed position. ble.sh can follow the Readline behavior.

I adjusted the behavior in commit 36ab934.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants