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 } } diff --git a/test/regression/3733-modeline-parsing-off-by-one-line/cmd b/test/regression/3733-modeline-parsing-off-by-one-line/cmd new file mode 100644 index 00000000..344c7543 --- /dev/null +++ b/test/regression/3733-modeline-parsing-off-by-one-line/cmd @@ -0,0 +1,3 @@ +:modeline-parse +% +:exec c %opt{tabstop} diff --git a/test/regression/3733-modeline-parsing-off-by-one-line/in b/test/regression/3733-modeline-parsing-off-by-one-line/in new file mode 100644 index 00000000..58f3ec24 --- /dev/null +++ b/test/regression/3733-modeline-parsing-off-by-one-line/in @@ -0,0 +1,7 @@ +# kak:tabstop=1: +# kak:tabstop=2: +# kak:tabstop=3: +foo +foo +foo +foo diff --git a/test/regression/3733-modeline-parsing-off-by-one-line/out b/test/regression/3733-modeline-parsing-off-by-one-line/out new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/test/regression/3733-modeline-parsing-off-by-one-line/out @@ -0,0 +1 @@ +1 diff --git a/test/regression/3733-modeline-parsing-off-by-one-line/rc b/test/regression/3733-modeline-parsing-off-by-one-line/rc new file mode 100644 index 00000000..98e55e02 --- /dev/null +++ b/test/regression/3733-modeline-parsing-off-by-one-line/rc @@ -0,0 +1,2 @@ +source "%val{runtime}/rc/detection/modeline.kak" +set-option global modelines 1