summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-08-31 22:23:06 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-08-31 22:23:06 -0400
commit8cf3952f27a3f7895100ff547cf1c8cdfeee72f7 (patch)
tree22526ff467806642d60eee5ba4ab974be2104bfc /lua
parent2d63bca419e19a84024fb0e2a18f616e6a6881a7 (diff)
fix: Rendering sometimes didn't work
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin.lua16
-rw-r--r--lua/telescope/pickers.lua15
2 files changed, 25 insertions, 6 deletions
diff --git a/lua/telescope/builtin.lua b/lua/telescope/builtin.lua
index 43e57fc..5c25663 100644
--- a/lua/telescope/builtin.lua
+++ b/lua/telescope/builtin.lua
@@ -13,9 +13,23 @@ local utils = require('telescope.utils')
local builtin = {}
builtin.git_files = function(opts)
+ local make_entry = (
+ opts.shorten_path
+ and function(value)
+ local result = {
+ valid = true,
+ display = utils.path_shorten(value),
+ ordinal = value,
+ value = value
+ }
+
+ return result
+ end)
+
+ or nil
pickers.new(opts, {
prompt = 'Git File',
- finder = finders.new_oneshot_job({ "git", "ls-files" }),
+ finder = finders.new_oneshot_job({ "git", "ls-files" }, make_entry),
previewer = previewers.cat,
sorter = sorters.get_norcalli_sorter(),
}):find()
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index 612dbab..fd1b615 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -161,6 +161,8 @@ function Picker:get_window_options(max_columns, max_lines, prompt_title)
end
function Picker:find()
+ self:reset_selection()
+
local prompt_string = assert(self.prompt, "Prompt is required.")
local finder = assert(self.finder, "Finder is required to do picking")
local sorter = self.sorter
@@ -408,6 +410,11 @@ function Picker:move_selection(change)
self:set_selection(self:get_selection_row() + change)
end
+function Picker:reset_selection()
+ self._selection = nil
+ self._selection_row = nil
+end
+
function Picker:set_selection(row)
if row > self.max_results then
row = self.max_results
@@ -416,11 +423,6 @@ function Picker:set_selection(row)
end
local entry = self.manager:get_entry(self.max_results - row + 1)
- if entry == self._selection and row == self._selection_row then
- log.trace("Same entry as before. Skipping set")
- return
- end
-
local status = state.get_status(self.prompt_bufnr)
local results_bufnr = status.results_bufnr
@@ -451,6 +453,9 @@ function Picker:set_selection(row)
-- end
-- self._match_id = vim.fn.matchaddpos("Conceal", { {row + 1, 1, 2} }, 0, -1, { window = results_win, conceal = ">" })
+ if self._selection == entry and self._selection_row == row then
+ return
+ end
-- TODO: Don't let you go over / under the buffer limits
-- TODO: Make sure you start exactly at the bottom selected