diff options
author | seifferth <43514227+seifferth@users.noreply.github.com> | 2022-09-05 17:37:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-05 17:37:52 +0200 |
commit | fb24ccf1b19fcc38de8cddbdd9883fff523d2e31 (patch) | |
tree | 4b7ddb9087660db5a411513a5e010f09e401ea65 | |
parent | a7f6b2ffd830063a0e88c5e228b7c4bbe8e3894c (diff) | |
parent | 5856eb36475eadd12398d1189f0fa0035f8a4d90 (diff) | |
download | vis-editorconfig-fb24ccf1b19fcc38de8cddbdd9883fff523d2e31.tar.gz |
Merge pull request #12 from fischerling/safe-empty-file
fix insert_final_newline for empty files
-rw-r--r-- | edconf.lua | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 |