m4xshen / hardtime.nvim

Establish good command workflow and quit bad habit
MIT License
1.5k stars 25 forks source link

Restricting <UP>, <DOWN>, <LEFT>, <RIGHT> act as disabling the keys #27

Closed Zhaith-Izaliel closed 1 year ago

Zhaith-Izaliel commented 1 year ago

Hi!

Expected Behavior

Setting the arrow keys as enabled while restricting them should trigger the count mechanism in their given mode.

Current Behavior

When setting the arrow keys as restricted while enabling them in the setup, they act as if they were disabled in the modes defined in the restricted_keys table, ie:

-- Hardtime
require('hardtime').setup {
  allow_different_key = true,
  enabled = true;
  restricted_keys = {
    ['<UP>'] = { 'n', 'x' },
    ['<DOWN>'] = { 'n', 'x' },
    ['<LEFT>'] = { 'n', 'x' },
    ['<RIGHT>'] = {'n', 'x' },
  },
  disabled_keys = {
    ['<UP>'] = {},
    ['<DOWN>'] = {},
    ['<LEFT>'] = {},
    ['<RIGHT>'] = {},
  },
}

And when I unset the tables for every arrow keys in the restricted_keys table like this:

-- ...
restricted_keys = {
    ['<UP>'] = {},
    ['<DOWN>'] = {},
    ['<LEFT>'] = {},
    ['<RIGHT>'] = {},
},
disabled_keys = {
    ['<UP>'] = {},
    ['<DOWN>'] = {},
    ['<LEFT>'] = {},
    ['<RIGHT>'] = {},
}

It allows me to use the arrow keys again.

Configuration used

Here is my configuration that triggers this behavior:

-- Hardtime
require('hardtime').setup {
  allow_different_key = true,
  enabled = true;
  restricted_keys = {
    ['<UP>'] = { 'n', 'x' },
    ['<DOWN>'] = { 'n', 'x' },
    ['<LEFT>'] = { 'n', 'x' },
    ['<RIGHT>'] = {'n', 'x' },
    ['+'] = {},
    ['-'] = {},
    ['g<UP>'] = { 'n', 'x' },
    ['g<DOWN>'] = { 'n', 'x' },
    ['<CR>'] = { 'n', 'x' },
    ['<C-M>'] = { 'n', 'x' },
    ['<C-N>'] = { 'n', 'x' },
    ['<C-P>'] = { 'n', 'x' },
  },
  disabled_keys = {
    ['<UP>'] = {},
    ['<DOWN>'] = {},
    ['<LEFT>'] = {},
    ['<RIGHT>'] = {},
  },
}

Have a nice day!

m4xshen commented 1 year ago

Thanks for the detailed issue report!