Skip to content

Commit

Permalink
fix(view): restore loc on first render and dont delete last loc if tr…
Browse files Browse the repository at this point in the history
…ouble window was never visisted. See #367
  • Loading branch information
folke committed May 30, 2024
1 parent 045fede commit 51bf510
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/trouble/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Window = require("trouble.view.window")
---@field sections trouble.Section[]
---@field renderer trouble.Render
---@field first_update? boolean
---@field first_render? boolean
---@field moving uv_timer_t
---@field state table<string,any>
---@field private _main? trouble.Main
Expand All @@ -36,6 +37,7 @@ function M.new(opts)
self.state = {}
self.opts = opts or {}
self.first_update = true
self.first_render = true
self.opts.win = self.opts.win or {}
self.opts.win.on_mount = function()
self:on_mount()
Expand Down Expand Up @@ -468,10 +470,10 @@ function M:render()
end

local loc = self:at()
local restore_loc = self.opts.restore and M._last[self.opts.mode or ""]
local restore_loc = self.opts.restore and self.first_render and M._last[self.opts.mode or ""]
if restore_loc then
loc = restore_loc
M._last[self.opts.mode or ""] = nil
self.first_render = false
end

-- render sections
Expand Down

0 comments on commit 51bf510

Please sign in to comment.