Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compat): add missing nil checks #33

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.3.1] - 2023-10-31

## Fixed
- Neovim 0.9 compatibility layer: Missing `nil` checks [[#32](https://github.com/mrcjkb/rustaceanvim/issues/32)].

## [3.3.0] - 2023-10-30

### Added
Expand Down
9 changes: 7 additions & 2 deletions lua/rustaceanvim/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ M.uv = vim.uv or vim.loop
M.system = vim.system
-- wrapper around vim.fn.system to give it a similar API to vim.system
or function(cmd, opts, on_exit)
if opts.cwd then
---@cast cmd string[]
---@cast opts SystemOpts | nil
---@cast on_exit fun(sc: vim.SystemCompleted) | nil
if opts and opts.cwd then
local shell = require('rustaceanvim.shell')
cmd = shell.chain_commands { 'cd ' .. opts.cwd, table.concat(cmd, ' ') }
---@cast cmd string
Expand All @@ -35,7 +38,9 @@ M.system = vim.system
stderr = not ok and (output or '') or nil,
code = vim.v.shell_error,
}
on_exit(systemObj)
if on_exit then
on_exit(systemObj)
end
return systemObj
end

Expand Down