gelguy / Cmd2.vim

cmdline-mode enhancement for Vim
MIT License
94 stars 4 forks source link

Can't delete characters with backspace #4

Closed alem0lars closed 9 years ago

alem0lars commented 9 years ago

I start cmd2, type something and try to press Backspace, however the characters are not deleted. Vim seems to ignore that hotkey.

gelguy commented 9 years ago

Can I ask for your OS and terminal (or gVim) for future troubleshooting?

I have noticed this occurring on slower terminals.

One solution I have found to work is

        \ 'loop_sleep': 0,

However, this makes Cmd2 not sleep (default 20ms) while waiting for input. This might consume more CPU than usual.

alem0lars commented 9 years ago

I'm using rxvt-unicode as terminal and Gentoo (GNU/Linux) as operating system.

alem0lars commented 9 years ago

It still doesn't work with that option, but I've noticed if I keep pressed backspace for 3/4 seconds, it will delete a single character; then I have to release the backspace and so on..

gelguy commented 9 years ago

Can you post a minmal .vimrc and steps to reproduce?

I am unable to use rxvt-unicode, and it currently works fine on Ubuntu tsch and Windows cmd.exe.

If this is a rxvt-unicode issue, I might not be able to fix it as I am unable to test or troubleshoot. Pull requests are welcome.

alem0lars commented 9 years ago

This is the relevant config:

" {{{ Options.

let g:Cmd2_cmd_mappings = {
      \ 'iw': {'command': 'iw', 'type': 'text', 'flags': 'Cpv'},
      \ 'ap': {'command': 'ap', 'type': 'line', 'flags': 'pv'},
      \ '^': {'command': '^', 'type': 'normal!', 'flags': 'r'},
      \ 'w': {'command': 'Cmd2#functions#Cword',
          \ 'type': 'function', 'flags': 'Cr'},
      \ }

let g:Cmd2_options = {
      \   '_complete_ignorecase': 1,
      \   '_complete_uniq_ignorecase': 0,
      \   '_quicksearch_ignorecase': 1,
      \   '_complete_start_pattern': '\<\(\k\+\(_\|\#\)\)\?',
      \   '_complete_fuzzy': 1,
      \   '_suggest_render': 'Cmd2#render#New().WithInsertCursor().WithAirlineMenu()',
      \   'loop_sleep': 0,
      \   'menu_hl': 'airline_x',
      \   'menu_selected_hl': 'airline_y',
      \   'menu_separator_hl': 'airline_x',
      \ }

" Character to type to start wildcard expansion in the command-line.
set wildcharm=<Tab>

" }}}

" {{{ Configure hotkeys.

" : or /: Enable Cmd2 automatically.
nmap : :<F11>
nmap / /<F11>

" <F11>: Enable Cmd2 manually.
cmap <F11> <Plug>(Cmd2Suggest)

" <Tab>: Perform completion using Cmd2.
cmap <expr> <Tab> Cmd2#ext#complete#InContext() ?
      \ '\<Plug>(Cmd2Complete)' :
      \ '\<Tab>'

" }}}
gelguy commented 9 years ago

I am unable to reproduce it on tsch or cmd.exe.

Does this issue occur under specific circumstances? e.g. large file, mutiple terminal sessions, long search string, etc.

I am trying to figure out where input keys can be dropped other than in :sleep.

alem0lars commented 9 years ago

Now it's working. I've changed nothing (i.e. 'loop_sleep': 0 fixed) but the problem is sometimes cmd2 isn't picking some configurations.

I mean, I've said that it didn't fix because in the first 5 / 6 tries it didn't work. Now it's working.

This is the same problem of #3 when I've said I had a white statusbar.. The problem gone away. Sometimes I still see the white bar and some times I cannot use backspace.

It seems those 2 options aren't picked sometimes.. It's strange..

Have you experienced something similar?

gelguy commented 9 years ago

Thanks for identifying the sleep issue.

Are you restarting vim each time you change the configurations? Cmd2 does not automatically update its variables when you change the Cmd2_options dictionary and source. The variable itself g:Cmd2_{variable} has to be changed by itself.

A quick script I use to force the options to update

  if exists('g:Cmd2_default_options')
    let s:options = extend(copy(g:Cmd2_default_options), g:Cmd2_options, 'force')
    for key in keys(s:options)
      if exists('g:Cmd2_' . key)
        unlet g:Cmd2_{key}
      endif
      let g:Cmd2_{key} = s:options[key]
    endfor
  endif

Place this after declaring the g:Cmd2_options dictionary.

alem0lars commented 9 years ago

It seems to work now..

I will close the issue in a week (to be sure it's really fixed).

Thanks a lot for the awesome support :smile:

gelguy commented 9 years ago

I have done an update so the script can be reduced to

  if exists('g:Cmd2_default_options')
    call Cmd2#init#Options(g:Cmd2_default_options)
  endif

Thanks for using the plugin!

alem0lars commented 9 years ago

It works correctly :) Thanks