diff options
| author | Luke Kershaw <35707277+l-kershaw@users.noreply.github.com> | 2021-10-21 10:46:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-21 10:46:32 +0100 |
| commit | f56222738b719f5ae94ed85fdf080690371da0b9 (patch) | |
| tree | 0720421cb527d8f834f63438663f92d2dab21feb /lua | |
| parent | a0835edd86bf13bf2d431632ce2ca128e04f3bf0 (diff) | |
fix: always remove previous caret when change selection (#1364)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/pickers.lua | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index f49920a..33129ca 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -833,25 +833,20 @@ function Picker:set_selection(row) local set_ok, set_errmsg = pcall(function() local prompt = self:_get_prompt() - -- Handle adding '> ' to beginning of selections - if self._selection_row then + -- Handle removing '> ' from beginning of previous selection (if still visible) + if self._selection_entry and self.manager:find_entry(self._selection_entry) then + -- Find the (possibly new) row of the old selection + local row_old_selection = self:get_row(self.manager:find_entry(self._selection_entry)) -- Only change the first couple characters, nvim_buf_set_text leaves the existing highlights a.nvim_buf_set_text( results_bufnr, - self._selection_row, + row_old_selection, 0, - self._selection_row, + row_old_selection, #self.selection_caret, { self.entry_prefix } ) - self.highlighter:hi_multiselect(self._selection_row, self:is_multi_selected(self._selection_entry)) - - -- local display = a.nvim_buf_get_lines(results_bufnr, old_row, old_row + 1, false)[1] - -- display = ' ' .. display - -- a.nvim_buf_set_lines(results_bufnr, old_row, old_row + 1, false, {display}) - - -- self.highlighter:hi_display(old_row, ' ', display_highlights) - -- self.highlighter:hi_sorter(old_row, prompt, display) + self.highlighter:hi_multiselect(row_old_selection, self:is_multi_selected(self._selection_entry)) end local caret = self.selection_caret |
