summaryrefslogtreecommitdiff
path: root/lua/telescope/actions/set.lua
diff options
context:
space:
mode:
authorAbel Mulugeta <abelmul@users.noreply.github.com>2022-01-09 20:49:19 +0300
committerGitHub <noreply@github.com>2022-01-09 18:49:19 +0100
commit01426c491b2b612b48f48b26e2e77679006999d3 (patch)
treeae695118ab94c5f81137478cfd448d5050a1ed05 /lua/telescope/actions/set.lua
parent24046b2361d9591b3381f31f38f24ef8e85b2f8f (diff)
fix: folding when a file is opened (#1643)
* fix: folding after a file is opened fixes #559 * fix: wrap nvim_win_set_cursor in autocmd * chore: Cleanup folding fix * explain the reason behind the autocmd Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
Diffstat (limited to 'lua/telescope/actions/set.lua')
-rw-r--r--lua/telescope/actions/set.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/lua/telescope/actions/set.lua b/lua/telescope/actions/set.lua
index 81f9bc5..85d2923 100644
--- a/lua/telescope/actions/set.lua
+++ b/lua/telescope/actions/set.lua
@@ -12,7 +12,6 @@
local a = vim.api
-local log = require "telescope.log"
local Path = require "plenary.path"
local state = require "telescope.state"
@@ -129,19 +128,22 @@ action_set.edit = function(prompt_bufnr, command)
vim.api.nvim_buf_set_option(entry_bufnr, "buflisted", true)
end
edit_buffer(command, entry_bufnr)
+ require("telescope.actions.utils").__jump_to(row, col)
else
-- check if we didn't pick a different buffer
-- prevents restarting lsp server
if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then
filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd())
- pcall(vim.cmd, string.format("%s %s", command, filename))
- end
- end
-
- if row and col then
- local ok, err_msg = pcall(a.nvim_win_set_cursor, 0, { row, col })
- if not ok then
- log.debug("Failed to move to cursor:", err_msg, row, col)
+ -- Make sure we wait till we are back in insert mode before opening the file
+ -- This fixes foldes
+ vim.cmd(string.format(
+ [[%s :lua require("telescope.actions.utils").__open_file_at("%s", "%s", %s, %s)]],
+ "autocmd InsertLeave * ++once ++nested", -- open file as soon as we have left insert mode (fixes folding)
+ command,
+ filename,
+ row,
+ col
+ ))
end
end
end