aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseifferth <43514227+seifferth@users.noreply.github.com>2022-09-05 17:37:52 +0200
committerGitHub <noreply@github.com>2022-09-05 17:37:52 +0200
commitfb24ccf1b19fcc38de8cddbdd9883fff523d2e31 (patch)
tree4b7ddb9087660db5a411513a5e010f09e401ea65
parenta7f6b2ffd830063a0e88c5e228b7c4bbe8e3894c (diff)
parent5856eb36475eadd12398d1189f0fa0035f8a4d90 (diff)
downloadvis-editorconfig-fb24ccf1b19fcc38de8cddbdd9883fff523d2e31.tar.gz
Merge pull request #12 from fischerling/safe-empty-file
fix insert_final_newline for empty files
-rw-r--r--edconf.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/edconf.lua b/edconf.lua
index 25edf6b..64b9387 100644
--- a/edconf.lua
+++ b/edconf.lua
@@ -36,7 +36,7 @@ function insert_final_newline(file, path)
-- therefore respect edconf_hooks_enabled. Since this function runs
-- blazingly fast and scales with a complexity of O(1), however,
-- there is no need to disable it.
- if file:content(file.size-1, 1) ~= '\n' then
+ if file.size > 0 and file:content(file.size-1, 1) ~= '\n' then
file:insert(file.size, '\n')
end
end