diff --git a/lua/spacevim/api/prompt.lua b/lua/spacevim/api/prompt.lua index cc82ceee5..4122d828f 100644 --- a/lua/spacevim/api/prompt.lua +++ b/lua/spacevim/api/prompt.lua @@ -67,7 +67,8 @@ function M._handle_input(...) while not M._quit do local char = M.__vim.getchar() if M._function_key[char] ~= nil then - pcall(M._function_key[char]) + local ok, rst = pcall(M._function_key[char]) + if not ok then print(rst) end goto continue end if M._c_r_mode then diff --git a/lua/spacevim/plugin/flygrep.lua b/lua/spacevim/plugin/flygrep.lua index 5eecf0d4b..538aec50c 100644 --- a/lua/spacevim/plugin/flygrep.lua +++ b/lua/spacevim/plugin/flygrep.lua @@ -316,7 +316,7 @@ local function open_item(...) jobstop(grepid) end mpt._clear_prompt() - mpt._quit = 1 + mpt._quit = true local filename, liner, colum = get_file_pos(line) if previous_able then close_preview_win() @@ -369,6 +369,39 @@ local function toggle_expr_mode() .. mpt._prompt.cursor_end) end +local function apply_to_quickfix() + mpt._handle_fly = flygrep + if vim.fn.getbufline(buffer_id, 1)[1] ~= '' then + if grepid ~= 0 then + jobstop(grepid) + end + mpt._quit = true + if previous_able then + close_preview_win() + end + previous_able = false + local searching_result = vim.api.nvim_buf_get_lines(buffer_id, 0, -1, false) + close_flygrep_win() + update_history() + if vim.fn.empty(searching_result) == 0 then + -- vim.cmd('cgetexpr ' .. vim.fn.join(searching_result, "\n")) + -- vim.cmd([[ + -- cgetexpr join(luaeval(searching_result), "\n") + -- ]]) + -- vim.fn.setqflist({}) + vim.fn.setqflist({}, 'r', { + title = 'FlyGrep partten:' .. mpt._prompt.cursor_begin .. mpt._prompt.cursor_char .. mpt._prompt.cursor_end, + lines = searching_result + }) + mpt._clear_prompt() + vim.cmd('copen') + end + vim.cmd('noautocmd normal! :') + + + end +end + mpt._function_key = { [Key.t('')] = next_item, [Key.t('')] = next_item,