Skip to content

Commit e3a543b

Browse files
authored
fix(compat): add missing nil checks (#33)
1 parent f7415da commit e3a543b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.3.1] - 2023-10-31
9+
10+
## Fixed
11+
- Neovim 0.9 compatibility layer: Missing `nil` checks [[#32](https://github.com/mrcjkb/rustaceanvim/issues/32)].
12+
813
## [3.3.0] - 2023-10-30
914

1015
### Added

lua/rustaceanvim/compat.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ M.uv = vim.uv or vim.loop
2020
M.system = vim.system
2121
-- wrapper around vim.fn.system to give it a similar API to vim.system
2222
or function(cmd, opts, on_exit)
23-
if opts.cwd then
23+
---@cast cmd string[]
24+
---@cast opts SystemOpts | nil
25+
---@cast on_exit fun(sc: vim.SystemCompleted) | nil
26+
if opts and opts.cwd then
2427
local shell = require('rustaceanvim.shell')
2528
cmd = shell.chain_commands { 'cd ' .. opts.cwd, table.concat(cmd, ' ') }
2629
---@cast cmd string
@@ -35,7 +38,9 @@ M.system = vim.system
3538
stderr = not ok and (output or '') or nil,
3639
code = vim.v.shell_error,
3740
}
38-
on_exit(systemObj)
41+
if on_exit then
42+
on_exit(systemObj)
43+
end
3944
return systemObj
4045
end
4146

0 commit comments

Comments
 (0)