From 990f1df42391e508e55d86083e220c15cc1f2140 Mon Sep 17 00:00:00 2001 From: xiantang Date: Sun, 28 Jan 2024 21:40:24 +0800 Subject: [PATCH] Check is command line window when try to move cursor --- lua/Navigator/navigate.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lua/Navigator/navigate.lua b/lua/Navigator/navigate.lua index 12af69b..9d61724 100644 --- a/lua/Navigator/navigate.lua +++ b/lua/Navigator/navigate.lua @@ -66,6 +66,16 @@ local function back_to_mux(at_edge) return N.last_pane or at_edge end +---Checks whether is command-line window +---@return boolean +local function is_command_line_window() + local window_type = vim.fn.getcmdwintype() + if window_type == ':' then + return true + end + return false +end + ---For smoothly navigating through neovim splits and mux panes ---@param direction string function N.navigate(direction) @@ -74,7 +84,11 @@ function N.navigate(direction) local mux_last_pane = direction == 'p' and N.last_pane if not mux_last_pane then - cmd('wincmd ' .. direction) + if is_command_line_window() then + print('Vim(wincmd):E11: Invalid in command-line window; executes, CTRL-C quits') + else + cmd('wincmd ' .. direction) + end end -- After navigation, if the old window and new window matches