From bf2442eaf6b116321dda12ee73a37c4e733eefb8 Mon Sep 17 00:00:00 2001 From: William Boman Date: Fri, 29 Jul 2022 01:28:01 +0200 Subject: fix(ui): don't call terminate handler when setting up handle (#190) The terminate handler should only really be called when the handle is terminated. By calling it immediately (to initialize UI state), any queued packages would be reset to either the "installed" or "uninstalled" group, when they really should remain "queued". --- lua/mason-core/ui/display.lua | 2 -- lua/mason/ui/instance.lua | 10 ++++------ 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'lua') diff --git a/lua/mason-core/ui/display.lua b/lua/mason-core/ui/display.lua index 285a153a..d1c2985a 100644 --- a/lua/mason-core/ui/display.lua +++ b/lua/mason-core/ui/display.lua @@ -245,8 +245,6 @@ function M.new_view_only_win(name, filetype) local draw = function(view) local win_valid = win_id ~= nil and vim.api.nvim_win_is_valid(win_id) local buf_valid = bufnr ~= nil and vim.api.nvim_buf_is_valid(bufnr) - log.fmt_trace("got bufnr=%s", bufnr) - log.fmt_trace("got win_id=%s", win_id) if not win_valid or not buf_valid then -- the window has been closed or the buffer is somehow no longer valid diff --git a/lua/mason/ui/instance.lua b/lua/mason/ui/instance.lua index 7fcf2452..a4234523 100644 --- a/lua/mason/ui/instance.lua +++ b/lua/mason/ui/instance.lua @@ -178,11 +178,10 @@ end ---@param handle InstallHandle local function setup_handle(handle) - ---@param new_state InstallHandleState - local function handle_state_change(new_state) - if new_state == "QUEUED" then + local function handle_state_change() + if handle.state == "QUEUED" then mutate_package_grouping(handle.package, "queued", true) - elseif new_state == "ACTIVE" then + elseif handle.state == "ACTIVE" then mutate_package_grouping(handle.package, "installing", true) end end @@ -234,8 +233,7 @@ local function setup_handle(handle) handle:on("stderr", handle_output) -- hydrate initial state - handle_state_change(handle.state) - handle_terminate() + handle_state_change() handle_spawnhandle_change() mutate_state(function(state) state.packages.states[handle.package.name].tailed_output = {} -- cgit v1.2.3-70-g09d2