From 74874aa4b70ed0bcd2e8c36054c16479a4789f09 Mon Sep 17 00:00:00 2001 From: throwawayaccount12345-1 <77868642+throwawayaccount12345-1@users.noreply.github.com> Date: Fri, 31 Dec 2021 11:02:15 -0300 Subject: [PATCH] modeline-parse: parse `set` and `:` correctly When `set` or `se` is found at the start of the modeline, it should stop parsing options after `:`. When `modeline-parse` is called in the following file, it should _not_ recognize `tabstop=4` and `invalid_option=3`. ``` # kak: set indentwidth=0 tabstop=16: tabstop=4 invalid_option=3 ``` More info: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline --- rc/detection/modeline.kak | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rc/detection/modeline.kak b/rc/detection/modeline.kak index 55cba460..a35af3c7 100644 --- a/rc/detection/modeline.kak +++ b/rc/detection/modeline.kak @@ -86,12 +86,12 @@ define-command -hidden modeline-parse-impl %{ # - the trailing text after the last option, and an optional ':' sign before it # It will also convert the ':' seperators beween the option=value pairs # More info: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline - printf %s "${kak_selection}" | sed \ - -e 's/^[^:]\{1,\}://' \ - -e 's/[ \t]*set\{0,1\}[ \t]//' \ - -e 's/:[^a-zA-Z0-9_=-]*$//' \ - -e 's/:/ /g' \ - | tr ' ' '\n' \ + printf %s "${kak_selection}" | sed \ + -e 's/^[^:]\{1,\}://' \ + -e 's/[ \t]*set\{0,1\}[ \t]\([^:]*\).*$/\1/' \ + -e 's/:[^a-zA-Z0-9_=-]*$//' \ + -e 's/:/ /g' \ + | tr ' ' '\n' \ | while read -r option; do name_option="${option%%=*}" value_option="${option#*=}"