The default filetype detection algorithm only checks the last lines of
.txt files for "ft=help" before setting the filetype to "text". Since
there was an empty line at the end, the help page was getting marked as
having filetype text first, and then help, which meant both autocmds
were triggered. This fixes that by removing the extraneous newline; note
that there is still a newline at the end of file, as is customary, and
this just removes the second, unnecessary newline.
Furthermore, this simplifies the logic for "gen_help.lua" and increases
its robustness by using the "io.lines" function rather than reading the
entire file as a string and using regular expressions to split it into
lines.
The default filetype detection algorithm only checks the last lines of .txt files for "ft=help" before setting the filetype to "text". Since there was an empty line at the end, the help page was getting marked as having filetype text first, and then help, which meant both autocmds were triggered. This fixes that by removing the extraneous newline; note that there is still a newline at the end of file, as is customary, and this just removes the second, unnecessary newline.
Furthermore, this simplifies the logic for "gen_help.lua" and increases its robustness by using the "io.lines" function rather than reading the entire file as a string and using regular expressions to split it into lines.