Skip to content

Commit

Permalink
fix: check that view is valid before render and focus (#319)
Browse files Browse the repository at this point in the history
* fix: add validity checks before render and focus

* chore: ignore .DS_Store
  • Loading branch information
MariaSolOs committed Jul 28, 2023
1 parent fc4bb22 commit 81e1643
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ debug
foo.*
*.log
data
.DS_Store
8 changes: 8 additions & 0 deletions lua/trouble/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ end

---@param text Text
function View:render(text)
if not self:is_valid() then
return
end

self:unlock()
self:set_lines(text.lines)
self:lock()
Expand Down Expand Up @@ -314,6 +318,10 @@ function View:on_win_enter()
end

function View:focus()
if not self:is_valid() then
return
end

View.switch_to(self.win, self.buf)
local line = self:get_line()
if line == 1 then
Expand Down

0 comments on commit 81e1643

Please sign in to comment.