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

"^A" is inserted at old cursor position in vi mode #5

Open
randvoorhies opened this issue Apr 5, 2017 · 5 comments
Open

"^A" is inserted at old cursor position in vi mode #5

randvoorhies opened this issue Apr 5, 2017 · 5 comments

Comments

@randvoorhies
Copy link

If bash is in vi mode (set -o vi), then whenever the I jump to a new character a "^A" is inserted after the old cursor position.

Using bash version 3.2.20(1)-release (x86_64-pc-linux-gnu)

@Fakerr
Copy link
Owner

Fakerr commented Apr 5, 2017

Does it work correctly for you without vi mode ? I want to make sure this not due to the bash version.

@randvoorhies
Copy link
Author

Yup, works perfectly without vi mode. It looks like it's the \key1 binding to \C-a which goes to the beginning of the line in emacs mode, but just inserts a ^A in vi mode.

@randvoorhies
Copy link
Author

randvoorhies commented Apr 5, 2017

Things seem to work well if I just get rid of the ^A whenever we're in vi mode, e.g:

  # Key bindings. Before executing the main function, place the cursor at the begeninng of the command line (\key1).                                                                                                 
  if [[ ${SHELLOPTS} =~ (^|:)"vi"(:|$) ]]; then                                                                                                                                                                      
      bind '"\key1":""'                                                                                                                                                                                              
  else                                                                                                                                                                                                               
      bind '"\key1":"\C-a"'                                                                                                                                                                                          
  fi

The only thing that sucks here is that we bind when we source the plugin, which means that if we turn on vi mode later then we're out of luck.

@Fakerr
Copy link
Owner

Fakerr commented Apr 5, 2017

Hmm, I need to think about it. I'm not sure 100% that removing the "\C-a" will actually resolve the issue. I did it (placed the cursor at the beginning) to fix a displaying bug for some cases, but maybe it's no longer needed in vi mode. I'll try to do more tests.

@Fakerr
Copy link
Owner

Fakerr commented Apr 7, 2017

Indeed, removing it will not work properly. You can try your snippet with a command that takes 2 lines or more for example. You will see that things gonna be messed up. So placing the cursor at the beginning before executing the main function is mandatory, but not sure how to do it in vi mode. I'll try to figure out a way to fix that, but if you have any suggestion, don't hesitate :)

@Fakerr Fakerr closed this as completed Apr 7, 2017
@Fakerr Fakerr reopened this Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants