repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix(cmdline): update border highlight on format change in show

9366d5d4d2a9cd3767e788323a501319ec571303

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

The cmdline_pos event doesn't fire on keypresses - only cmdline_show
does. So format changes (e.g. : → :h) must be detected in show(),
not update_cursor(). Track fmt_changed and update winhighlight when
the format type changes between show() calls.

Changed files (1)

neovim/lua/bugabinga/cmdline/render.lua

Modified
78 78 local text = cmdline_state:text()
79 79 state.text = text
80 80 local fmt = format.detect(cmdline_state.firstc, text, cmdline_state.prompt)
81 + local fmt_changed = not state.current_fmt or fmt.type ~= state.current_fmt.type
81 82 state.current_fmt = fmt
82 83 local display_text = ' ' .. text .. ' '
83 84 local width = vim.o.columns
103 104 position.set_cmdline_anchor(anchor)
104 105 vim.g.ui_cmdline_pos = { anchor.screenpos.row, anchor.screenpos.col }
107 + if fmt_changed then
108 + vim.wo[win].winhighlight = get_winhighlight(fmt.type)
109 + end
106 110 vim.api.nvim_buf_set_lines(buf, 0, -1, false, { display_text })
107 111 vim.api.nvim_buf_clear_namespace(buf, ns, 0, -1)
108 112 local icon_hl = ICON_HIGHLIGHT_MAP[fmt.type] or 'CmdlineIconCmdline'