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
This commit is contained in:
throwawayaccount12345-1 2021-12-31 11:02:15 -03:00 committed by GitHub
parent f68e8313b2
commit 74874aa4b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,12 +86,12 @@ define-command -hidden modeline-parse-impl %{
# - the trailing text after the last option, and an optional ':' sign before it # - the trailing text after the last option, and an optional ':' sign before it
# It will also convert the ':' seperators beween the option=value pairs # It will also convert the ':' seperators beween the option=value pairs
# More info: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline # More info: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline
printf %s "${kak_selection}" | sed \ printf %s "${kak_selection}" | sed \
-e 's/^[^:]\{1,\}://' \ -e 's/^[^:]\{1,\}://' \
-e 's/[ \t]*set\{0,1\}[ \t]//' \ -e 's/[ \t]*set\{0,1\}[ \t]\([^:]*\).*$/\1/' \
-e 's/:[^a-zA-Z0-9_=-]*$//' \ -e 's/:[^a-zA-Z0-9_=-]*$//' \
-e 's/:/ /g' \ -e 's/:/ /g' \
| tr ' ' '\n' \ | tr ' ' '\n' \
| while read -r option; do | while read -r option; do
name_option="${option%%=*}" name_option="${option%%=*}"
value_option="${option#*=}" value_option="${option#*=}"