nnn.vim icon indicating copy to clipboard operation
nnn.vim copied to clipboard

Error when mapping action to <backspace>

Open heynemann opened this issue 2 years ago • 3 comments

Describe the bug

When adding action to call a function when <backspace> is pressed. I get an error:

Error detected while processing function nnn#select_action:
line    6:
E728: Using a Dictionary as a Number

To Reproduce

Add this config on top of nnn.vim:

function! QuitNNN()
    execute('normal! q')
endfunction

let g:nnn#action = { '<backspace>': funcref('QuitNNN') }
  1. Open vim
  2. Press key n
  3. Press key
  4. See error

Expected behavior

Should call my function (and in turn close explorer).

Environment:

  • OS: macos
  • Terminal: iterm2
  • Shell: zsh
  • Vim version: vim 8
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: latest on brew

heynemann avatar Mar 12 '22 18:03 heynemann

The problem seems to be related to explorer as using nnn#pick it works.

heynemann avatar Mar 12 '22 22:03 heynemann

It works now with any <c- key, but not with or . (and not in explorer, only in pick)

heynemann avatar Mar 12 '22 22:03 heynemann

I can reproduce the problem. However, I would suggest an alternative (better) way to achieve the behavior you want:

autocmd FileType nnn tnoremap <buffer><silent> <backspace> q

Or place the mapping in ftplugin/nnn.vim.

A problem though with mapping backspace with q is that, backspace will not work as intended in moments like entering texts in renaming files/new file name etc.

mcchrish avatar Mar 14 '22 08:03 mcchrish