From 95c095f3fb52a539b0f516a05fb4267f317e0690 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 16 Sep 2020 10:55:36 +0300 Subject: [PATCH] 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. --- rc/detection/modeline.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/detection/modeline.kak b/rc/detection/modeline.kak index 1a343448..00d2fcdc 100644 --- a/rc/detection/modeline.kak +++ b/rc/detection/modeline.kak @@ -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 s\A|.\z %opt{modelines}k %opt{modelines}X \ + execute-keys "s(?S)\A(.+\n){,%opt{modelines}}|(.+\n){,%opt{modelines}}\z" \ s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+ evaluate-commands -draft -itersel modeline-parse-impl } }