diff options
| author | William Boman <william@redwill.se> | 2022-12-27 06:09:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-27 06:09:24 +0100 |
| commit | 6a39b2f1123fccc6a869eecca1abde1736fcf3a5 (patch) | |
| tree | b509d58bce86c95d0823e72e6e6f689f55f3c3d1 /lua | |
| parent | refactor: interact with libuv pipes in async context (#808) (diff) | |
| download | mason-6a39b2f1123fccc6a869eecca1abde1736fcf3a5.tar mason-6a39b2f1123fccc6a869eecca1abde1736fcf3a5.tar.gz mason-6a39b2f1123fccc6a869eecca1abde1736fcf3a5.tar.bz2 mason-6a39b2f1123fccc6a869eecca1abde1736fcf3a5.tar.lz mason-6a39b2f1123fccc6a869eecca1abde1736fcf3a5.tar.xz mason-6a39b2f1123fccc6a869eecca1abde1736fcf3a5.tar.zst mason-6a39b2f1123fccc6a869eecca1abde1736fcf3a5.zip | |
fix(api/command): instantiate UI before package installation (#810)
This fixes situations where the UI would be come desynced should a
package installation complete immediately (i.e. in the very same event
loop as it was started in).
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason/api/command.lua | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lua/mason/api/command.lua b/lua/mason/api/command.lua index 8cadbc33..3343ea1d 100644 --- a/lua/mason/api/command.lua +++ b/lua/mason/api/command.lua @@ -94,18 +94,20 @@ local function MasonInstall(package_specifiers, opts) return end - ---@type InstallHandle[] - local handles = _.map(function(pkg_specifier) + local install_packages = _.map(function(pkg_specifier) local package_name, version = Package.Parse(pkg_specifier) local pkg = registry.get_package(package_name) return pkg:install { version = version, debug = opts.debug } - end, valid_packages) + end) if is_headless then - join_handles(handles) + join_handles(install_packages(valid_packages)) else local ui = require "mason.ui" ui.open() + -- Important: We start installation of packages _after_ opening the UI. This gives the UI components a chance to + -- register the necessary event handlers in time, avoiding desynced state. + install_packages(valid_packages) vim.schedule(function() ui.set_sticky_cursor "installing-section" end) |
