Skip to content

Commit

Permalink
perf: remove unnecessary update_winbar calls
Browse files Browse the repository at this point in the history
Since the winbar is now updated automatically, it's not necessary to update it explicitly. For some
reason, however, removing the `update_winbar` call in `switch_view_type()`
(`gitlab/actions/discussions/winbar.lua`) causes a minor screen flicker, so I've kept that one in.
  • Loading branch information
jakubbortlik committed Nov 23, 2024
1 parent 965bec2 commit e023653
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lua/gitlab/actions/discussions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ M.rebuild_view = function(unlinked, all)
else
M.rebuild_discussion_tree()
end
M.refresh_diagnostics_and_winbar()
M.refresh_diagnostics()
end)
end

Expand All @@ -73,7 +73,7 @@ end
M.initialize_discussions = function()
signs.setup_signs()
reviewer.set_callback_for_file_changed(function()
M.refresh_diagnostics_and_winbar()
M.refresh_diagnostics()
M.modifiable(false)
reviewer.set_reviewer_keymaps()
end)
Expand Down Expand Up @@ -103,11 +103,10 @@ M.modifiable = function(bool)
end

--- Take existing data and refresh the diagnostics, the winbar, and the signs
M.refresh_diagnostics_and_winbar = function()
M.refresh_diagnostics = function()
if state.settings.discussion_signs.enabled then
diagnostics.refresh_diagnostics()
end
winbar.update_winbar()
common.add_empty_titles()
state.discussion_tree.last_updated = os.time()
end
Expand Down Expand Up @@ -156,7 +155,7 @@ M.open = function(callback)
end

vim.schedule(function()
M.refresh_diagnostics_and_winbar()
M.refresh_diagnostics()
end)
end

Expand Down Expand Up @@ -587,7 +586,7 @@ M.set_tree_keymaps = function(tree, bufnr, unlinked)
if keymaps.discussion_tree.jump_to_reviewer then
vim.keymap.set("n", keymaps.discussion_tree.jump_to_reviewer, function()
if M.is_current_node_note(tree) then
common.jump_to_reviewer(tree, M.refresh_diagnostics_and_winbar)
common.jump_to_reviewer(tree, M.refresh_diagnostics)
end
end, { buffer = bufnr, desc = "Jump to reviewer", nowait = keymaps.discussion_tree.jump_to_reviewer_nowait })
end
Expand Down Expand Up @@ -793,7 +792,6 @@ end
---Toggle between draft mode (comments posted as drafts) and live mode (comments are posted immediately)
M.toggle_draft_mode = function()
state.settings.discussion_tree.draft_mode = not state.settings.discussion_tree.draft_mode
winbar.update_winbar()
end

---Indicates whether the node under the cursor is a draft note or not
Expand Down

0 comments on commit e023653

Please sign in to comment.