From f750159203077b00cecdd9f68c254aa70d10f879 Mon Sep 17 00:00:00 2001 From: oberblastmeister <61095988+oberblastmeister@users.noreply.github.com> Date: Tue, 5 Jan 2021 02:50:44 -0500 Subject: [PATCH] feat: add actions.get_current_line (#391) --- lua/telescope/actions/init.lua | 4 ++++ lua/telescope/pickers.lua | 3 +++ 2 files changed, 7 insertions(+) diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index fdd400c..6ffb3ef 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -43,6 +43,10 @@ function actions.get_selected_entry() return state.get_global_key('selected_entry') end +function actions.get_current_line() + return state.get_global_key('current_line') +end + function actions.preview_scrolling_up(prompt_bufnr) actions.get_current_picker(prompt_bufnr).previewer:scroll_fn(-30) end diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 96af5b6..67553c2 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -524,6 +524,9 @@ function Picker:find() error('Unknown selection strategy: ' .. selection_strategy) end + local current_line = vim.api.nvim_get_current_line():sub(self.prompt_prefix:len() + 1) + state.set_global_key('current_line', current_line) + self:clear_extra_rows(results_bufnr) self:highlight_displayed_rows(results_bufnr, prompt)