diff options
author | 2017-01-02 11:52:47 -0500 | |
---|---|---|
committer | 2017-01-02 11:52:47 -0500 | |
commit | 07293f5457565d00c9afdea83b4add12fa0d93c5 (patch) | |
tree | aa052f9f2be326d24d646d30accaa2eab052881a /core | |
parent | b0a4ea2d65ca25ec80222a99a9b1a5e0c35c2558 (diff) |
Improved LuaJIT compatibility; core/init.lua
Some third-party extensions make use of Lua 5.3's `table.insert()`.
Diffstat (limited to 'core')
-rw-r--r-- | core/init.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/core/init.lua b/core/init.lua index c0a21137..a7d2cca2 100644 --- a/core/init.lua +++ b/core/init.lua @@ -17,7 +17,16 @@ keys = require('keys') _M = {} -- language modules table -- LuaJIT compatibility. -if jit then module, package.searchers, bit32 = nil, package.loaders, bit end +if jit then + module, package.searchers, bit32 = nil, package.loaders, bit + -- In Lua 5.3, the `table` library respects metamethods. Redefine at least the + -- functions Textadept may depend on. + table.insert = function(list, pos, value) + if not value then value, pos = pos, #list + 1 end + for i = #list, pos, -1 do list[i + 1] = list[i] end + list[pos] = value + end +end -- pdcurses compatibility. if CURSES and WIN32 then function spawn(argv, cwd, ...) |