summaryrefslogtreecommitdiffstats
path: root/lua/core/misc.lua
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2024-04-19 22:32:17 -0400
committerSquibid <me@zacharyscheiman.com>2024-04-19 22:32:17 -0400
commit3ebe12e99d27da69abff1c4c0a07fa7668af8104 (patch)
tree18fbfc13b3c6c729763efd49e2d4976cbb9e3942 /lua/core/misc.lua
parent985b065925a920dc18809d2cc31c1798b2125bce (diff)
downloadnvim-3ebe12e99d27da69abff1c4c0a07fa7668af8104.tar.gz
nvim-3ebe12e99d27da69abff1c4c0a07fa7668af8104.tar.bz2
nvim-3ebe12e99d27da69abff1c4c0a07fa7668af8104.zip
make replaceword safer
Diffstat (limited to 'lua/core/misc.lua')
-rw-r--r--lua/core/misc.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/lua/core/misc.lua b/lua/core/misc.lua
index 1f6d427..b96855b 100644
--- a/lua/core/misc.lua
+++ b/lua/core/misc.lua
@@ -14,9 +14,12 @@ end
function M.replaceword(old, new)
local conf = vim.fn.stdpath("config").."/lua/conf/".."opts.lua"
local f = io.open(conf, "r")
+ if not f then return end
local new_content = f:read("*all"):gsub(old, new)
+ f:close()
f = io.open(conf, "w")
+ if not f then return end
f:write(new_content)
f:close()
end