From d9059413e2cac021795fa635d83768f5ae4c3c3b Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 14 Jun 2022 13:16:51 -0400 Subject: [PATCH] Fix inconsistent whitespace matching in regexps The \s and \S atoms consider space and tabs to be the only valid whitespace characters, while the [:space:] character class also includes control characters like newline and form feed. --- autoload/fugitive.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 5e6e0d1..0af0869 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -425,7 +425,7 @@ function! s:GitCmd() abort call add(list, '/usr/bin/env') endif while string =~# '\S' - let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^[:space:] |]\)\+') + let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^' . "\t" . ' |]\)\+') let string = strpart(string, len(arg)) let arg = substitute(arg, '^\s\+', '', '') let arg = substitute(arg, @@ -2027,7 +2027,7 @@ function! s:SplitExpandChain(string, ...) abort if string =~# '^\s*|' return [list, substitute(string, '^\s*', '', '')] endif - let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^[:space:] |]\)\+') + let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^' . "\t" . ' |]\)\+') let string = strpart(string, len(arg)) let arg = substitute(arg, '^\s\+', '', '') if !exists('seen_separator') @@ -5935,7 +5935,7 @@ function! s:ArgSplit(string) abort let string = a:string let args = [] while string =~# '\S' - let arg = matchstr(string, '^\s*\%(\\.\|[^[:space:]]\)\+') + let arg = matchstr(string, '^\s*\%(\\.\|\S\)\+') let string = strpart(string, len(arg)) let arg = substitute(arg, '^\s\+', '', '') call add(args, substitute(arg, '\\\+[|" ]', '\=submatch(0)[len(submatch(0))/2 : -1]', 'g'))