aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2025-03-03 16:10:48 +0100
committerWilliam Boman <william@redwill.se>2025-03-03 16:19:07 +0100
commiteb220f56b67ffb48bf2ecb11981096c877c9ea0a (patch)
tree6abf0e73da0f9dec1262427580fecdd36936beb8
parentfix(uninstaller): only unlink if recipt is found (diff)
downloadmason-eb220f56b67ffb48bf2ecb11981096c877c9ea0a.tar
mason-eb220f56b67ffb48bf2ecb11981096c877c9ea0a.tar.gz
mason-eb220f56b67ffb48bf2ecb11981096c877c9ea0a.tar.bz2
mason-eb220f56b67ffb48bf2ecb11981096c877c9ea0a.tar.lz
mason-eb220f56b67ffb48bf2ecb11981096c877c9ea0a.tar.xz
mason-eb220f56b67ffb48bf2ecb11981096c877c9ea0a.tar.zst
mason-eb220f56b67ffb48bf2ecb11981096c877c9ea0a.zip
fix(ui): fix initializing state
-rw-r--r--lua/mason/ui/components/main/package_list.lua13
-rw-r--r--lua/mason/ui/instance.lua32
2 files changed, 29 insertions, 16 deletions
diff --git a/lua/mason/ui/components/main/package_list.lua b/lua/mason/ui/components/main/package_list.lua
index ba05a9bd..8d1dc803 100644
--- a/lua/mason/ui/components/main/package_list.lua
+++ b/lua/mason/ui/components/main/package_list.lua
@@ -199,8 +199,19 @@ local function Installed(state)
Ui.When(state.packages.new_versions_check.is_checking, function()
local new_versions_check = state.packages.new_versions_check
local styling = new_versions_check.percentage_complete == 1 and p.highlight_block or p.muted_block
+ local is_all_registries_installed = _.all(_.prop "is_installed", state.info.registries)
+ local registry_count = #state.info.registries
+ local text
+ if registry_count > 1 then
+ text = p.Comment(
+ is_all_registries_installed and ("updating %d registries "):format(registry_count)
+ or ("installing %d registries "):format(registry_count)
+ )
+ else
+ text = p.Comment(is_all_registries_installed and "updating registry " or "installing registry ")
+ end
return Ui.VirtualTextNode {
- p.Comment "updating registry ",
+ text,
styling(("%-4s"):format(math.floor(new_versions_check.percentage_complete * 100) .. "%")),
styling((" "):rep(new_versions_check.percentage_complete * 15)),
}
diff --git a/lua/mason/ui/instance.lua b/lua/mason/ui/instance.lua
index 4302685a..3035d6c6 100644
--- a/lua/mason/ui/instance.lua
+++ b/lua/mason/ui/instance.lua
@@ -607,7 +607,12 @@ local function setup_package(pkg)
end
mutate_state(function(state)
- for _, group in ipairs { state.packages.installed, state.packages.uninstalled, state.packages.failed } do
+ for _, group in ipairs {
+ state.packages.installed,
+ state.packages.uninstalled,
+ state.packages.failed,
+ state.packages.outdated_packages,
+ } do
for i, existing_pkg in ipairs(group) do
if existing_pkg.name == pkg.name and pkg ~= existing_pkg then
-- New package instance (i.e. from a new, updated, registry source).
@@ -705,13 +710,19 @@ local function setup_packages(packages)
end)
end
-setup_packages(registry.get_all_packages())
update_registry_info()
-
-registry.refresh(function()
+if registry.sources:is_all_installed() then
setup_packages(registry.get_all_packages())
- update_registry_info()
-end)
+end
+
+if settings.current.ui.check_outdated_packages_on_open then
+ a.run(check_new_package_versions, function() end)
+else
+ registry.refresh(function()
+ setup_packages(registry.get_all_packages())
+ update_registry_info()
+ end)
+end
registry:on("update", function()
setup_packages(registry.get_all_packages())
@@ -726,15 +737,6 @@ window.init {
},
}
-if settings.current.ui.check_outdated_packages_on_open then
- vim.defer_fn(
- a.scope(function()
- check_new_package_versions()
- end),
- 100
- )
-end
-
return {
window = window,
set_view = function(view)