Skip to content

Commit

Permalink
Fix: Don't duplicate URL in plugin info display on toggle (#682)
Browse files Browse the repository at this point in the history
* FIX: Account for plugin name also appearing in URL in status display

This was causing us to be off-by-one in removing or adding lines to the display when toggling update information.

* FIX: Restore cursor position after toggling info
  • Loading branch information
wbthomason authored Nov 3, 2021
1 parent fae6749 commit 7f62848
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/packer/display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ local display_mt = {
return
end

local current_cursor_pos = api.nvim_win_get_cursor(0)
local plugin_name, cursor_pos = self:find_nearest_plugin()
if plugin_name == nil then
log.warn 'No plugin selected!'
Expand All @@ -622,6 +623,8 @@ local display_mt = {
else
log.info('No further information for ' .. plugin_name)
end

api.nvim_win_set_cursor(0, current_cursor_pos)
end,

diff = function(self)
Expand Down Expand Up @@ -708,12 +711,17 @@ local display_mt = {
if not self:valid_display() then
return
end

local cursor_pos = api.nvim_win_get_cursor(0)
-- TODO: this is a dumb hack
for i = cursor_pos[1], 1, -1 do
local curr_line = api.nvim_buf_get_lines(0, i - 1, i, true)[1]
for name, _ in pairs(self.items) do
if string.find(curr_line, name, 1, true) then
if string.find(curr_line, ' URL:', 1, true) then
i = i - 1
end

return name, { i, 0 }
end
end
Expand Down

0 comments on commit 7f62848

Please sign in to comment.