aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/lsnippets.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-02-10 21:31:53 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2008-02-10 21:31:53 -0500
commit2a8b91209627608fe61c21ec96de31b7fffcea94 (patch)
tree039767373d0a3f688c86cc8c1692fc422b80696d /modules/textadept/lsnippets.lua
parent655d3222b8e242bcdb96e9458dc311aee1a658e5 (diff)
downloadtextadept-2a8b91209627608fe61c21ec96de31b7fffcea94.tar.gz
textadept-2a8b91209627608fe61c21ec96de31b7fffcea94.zip
Instead of io.popen():read(), a file descriptor is kept and close()'d afterward.
Diffstat (limited to 'modules/textadept/lsnippets.lua')
-rw-r--r--modules/textadept/lsnippets.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/textadept/lsnippets.lua b/modules/textadept/lsnippets.lua
index 7a8a4e13..4fa73b96 100644
--- a/modules/textadept/lsnippets.lua
+++ b/modules/textadept/lsnippets.lua
@@ -134,7 +134,12 @@ function insert(s_text)
-- Execute Lua and shell code.
s_text = s_text:gsub('%%(%b())', run_lua_code)
s_text = s_text:gsub('`([^`]+)`',
- function(code) return io.popen(code):read('*all'):sub(1, -2) end)
+ function(code)
+ local p = io.popen(code)
+ local out = p:read('*all'):sub(1, -2)
+ p:close()
+ return out
+ end)
-- Initialize the new snippet. If one is running, push it onto the stack.
if snippet.index then snippet_stack[#snippet_stack + 1] = snippet end