patch 9.1.1396: 'errorformat' is a global option
Problem: The 'grepformat' option is global option, but it would be
useful to have it buffer-local, similar to 'errorformat' and
other quickfix related options (Dani Dickstein)
Solution: Add the necessary code to support global-local 'grepformat',
allowing different buffers to parse different grep output
formats (glepnir)
fixes: #17316
closes: #17315
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index fe85887..dc2a2a4 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -2379,6 +2379,25 @@
call s:test_xgrep('l')
endfunc
+func Test_local_grepformat()
+ let save_grepformat = &grepformat
+ set grepformat=%f:%l:%m
+ " The following line are used for the local grep test. Don't remove.
+ " UNIQUEPREFIX:2:3: Local grepformat test
+ new
+ setlocal grepformat=UNIQUEPREFIX:%c:%n:%m
+ call assert_equal('UNIQUEPREFIX:%c:%n:%m', &l:grepformat)
+ call assert_equal('%f:%l:%m', &g:grepformat)
+
+ set grepprg=internal
+ silent grep "^[[:space:]]*\" UNIQUEPREFIX:" test_quickfix.vim
+ call assert_equal(1, len(getqflist()))
+ set grepprg&vim
+
+ bwipe!
+ let &grepformat = save_grepformat
+endfunc
+
func Test_two_windows()
" Use one 'errorformat' for two windows. Add an expression to each of them,
" make sure they each keep their own state.