Skip to content

Commit 1fc42e6

Browse files
committed
fix(ffi): 'expr_map_lock' was added in 0.9.0
(rel. #357)
1 parent ef48bec commit 1fc42e6

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lua/diffview/ffi.lua

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ local C = ffi.C
44

55
local M = setmetatable({}, { __index = ffi })
66

7+
local HAS_NVIM_0_9 = vim.fn.has("nvim-0.9") == 1
8+
79
---Check if the |textlock| is active.
810
---@return boolean
911
function M.nvim_is_textlocked()
@@ -15,7 +17,12 @@ end
1517
---@return boolean
1618
function M.nvim_is_locked()
1719
if vim.in_fast_event() then return true end
18-
return C.textlock > 0 or C.allbuf_lock > 0 or C.expr_map_lock > 0
20+
21+
if HAS_NVIM_0_9 then
22+
return C.textlock > 0 or C.allbuf_lock > 0 or C.expr_map_lock > 0
23+
end
24+
25+
return C.textlock > 0 or C.allbuf_lock > 0 or C.ex_normal_lock > 0
1926
end
2027

2128
ffi.cdef([[
@@ -26,9 +33,18 @@ ffi.cdef([[
2633
/// Non-zero when no buffer name can be changed, no buffer can be deleted and
2734
/// current directory can't be changed. Used for SwapExists et al.
2835
extern int allbuf_lock;
29-
30-
/// Running expr mapping, prevent use of ex_normal() and text changes
31-
extern int expr_map_lock;
3236
]])
3337

38+
if HAS_NVIM_0_9 then
39+
ffi.cdef([[
40+
/// Running expr mapping, prevent use of ex_normal() and text changes
41+
extern int expr_map_lock;
42+
]])
43+
else
44+
ffi.cdef([[
45+
/// prevent use of ex_normal()
46+
extern int ex_normal_lock;
47+
]])
48+
end
49+
3450
return M

0 commit comments

Comments
 (0)