rc modeline: Don't select more lines than configured

This commit addresses an off-by-one error that selected `modelines`+1
lines when looking for modelines in a buffer.

Note that setting `modelines` to 0 will still select one line.

Fixes #3733.
This commit is contained in:
Frank LENORMAND 2020-09-16 10:55:36 +03:00
parent ec3d7c3104
commit 95c095f3fb

View File

@ -96,7 +96,7 @@ define-command -hidden modeline-parse-impl %{
# [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{
try %{ evaluate-commands -draft %{
execute-keys <percent> s\A|.\z<ret> %opt{modelines}k <a-x> %opt{modelines}X \
execute-keys <percent> "s(?S)\A(.+\n){,%opt{modelines}}|(.+\n){,%opt{modelines}}\z<ret>" \
s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+<ret> <a-x>
evaluate-commands -draft -itersel modeline-parse-impl
} }