summaryrefslogtreecommitdiff
path: root/lua/telescope/actions/utils.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/utils.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/utils.lua')
-rw-r--r--lua/telescope/actions/utils.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/lua/telescope/actions/utils.lua b/lua/telescope/actions/utils.lua
index 4d0c17d..01d9e79 100644
--- a/lua/telescope/actions/utils.lua
+++ b/lua/telescope/actions/utils.lua
@@ -6,6 +6,7 @@
--- Generally used from within other |telescope.actions|
---@brief ]]
+local log = require "telescope.log"
local action_state = require "telescope.actions.state"
local utils = {}
@@ -102,4 +103,22 @@ function utils.get_registered_mappings(prompt_bufnr)
return ret
end
+--- Internal function for autocmd
+--- Please dont call (subject to change)
+function utils.__jump_to(row, col)
+ if row and col then
+ local ok, err_msg = pcall(vim.api.nvim_win_set_cursor, 0, { row, col })
+ if not ok then
+ log.debug("Failed to move to cursor:", err_msg, row, col)
+ end
+ end
+end
+
+--- Internal function for autocmd
+--- Please dont call (subject to change)
+function utils.__open_file_at(command, filename, row, col)
+ vim.cmd(string.format([[:%s %s]], command, filename))
+ utils.__jump_to(row, col)
+end
+
return utils