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

Bug: Hitting <C-l> does not immediately clear results from searchcount component #1245

Open
2 tasks done
camoz opened this issue May 23, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@camoz
Copy link

camoz commented May 23, 2024

Self Checks

  • I'm using the latest lualine.
  • I didn't find the issue in existing issues or PRs.

How to reproduce the problem

  1. have lualine configured to use searchcount component
  2. search something in the buffer, e.g. input /a<CR>
  3. observe how searchcount component becomes visible
  4. press <C-l> to clear highlighting of current search results

Expected behaviour

searchcount component becomes instantly invisible.

Actual behaviour

searchcount component does not become instantly invisible. It becomes invisible after the remaining time until lualine refreshes.

Minimal config to reproduce the issue

Lualine default config with following changes:

  • searchcount component added to section lualine_x
  • increase statusline refresh to 3000 ms, to make issue more visible
require('lualine').setup {
  options = {
    icons_enabled = true,
    theme = 'auto',
    component_separators = { left = '', right = ''},
    section_separators = { left = '', right = ''},
    disabled_filetypes = {
      statusline = {},
      winbar = {},
    },
    ignore_focus = {},
    always_divide_middle = true,
    globalstatus = false,
    refresh = {
      statusline = 3000,
      tabline = 1000,
      winbar = 1000,
    }
  },
  sections = {
    lualine_a = {'mode'},
    lualine_b = {'branch', 'diff', 'diagnostics'},
    lualine_c = {'filename'},
    lualine_x = {'searchcount', 'encoding', 'fileformat', 'filetype'},
    lualine_y = {'progress'},
    lualine_z = {'location'}
  },
  inactive_sections = {
    lualine_a = {},
    lualine_b = {},
    lualine_c = {'filename'},
    lualine_x = {'location'},
    lualine_y = {},
    lualine_z = {}
  },
  tabline = {},
  winbar = {},
  inactive_winbar = {},
  extensions = {}
}

Additional information

Neovim 0.10 by default maps <C-l> to <Cmd>nohlsearch|diffupdate|normal! <C-L><CR>, see :nmap <C-l> and :help default-mappings.

Workaround:

-- Overwrite neovim's <C-l> mapping using : instead of <Cmd>
vim.keymap.set('n', '<C-l>', ':nohlsearch|diffupdate|normal! <C-L><CR>')

I think this works because :, unlike <Cmd>, triggers a mode change, and lualine refreshes on ModeChanged.

@camoz camoz added the bug Something isn't working label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant