mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-25 21:16:38 +03:00
rc grep/make: never match multiline filenames
If a user modifies a grep buffer, we can end up in weird situations
where we try match a filename over multiple lines.
Let's rule out newlines in filenames here. There is an argument
this is a case of GIGO but we already do this for the corresponding
highlighters.
We also do it in make.kak, see ca225ad4d
(Cleanup make.kak and optimize
the make-next/make-prev regexes, 2016-12-09). There is one case left
where a filename would theoretically span multiple lines. Fix and
optimize this too.
This commit is contained in:
parent
20d353936e
commit
40ffd5ff3b
@ -54,7 +54,7 @@ declare-option -docstring "name of the client in which all source code jumps wil
|
||||
define-command -hidden grep-jump %{
|
||||
evaluate-commands %{ # use evaluate-commands to ensure jumps are collapsed
|
||||
try %{
|
||||
execute-keys 'xs^([^:]+):(\d+):(\d+)?<ret>'
|
||||
execute-keys 'xs^([^:\n]+):(\d+):(\d+)?<ret>'
|
||||
set-option buffer grep_current_line %val{cursor_line}
|
||||
evaluate-commands -try-client %opt{jumpclient} -verbatim -- edit -existing %reg{1} %reg{2} %reg{3}
|
||||
try %{ focus %opt{jumpclient} }
|
||||
@ -68,7 +68,7 @@ define-command grep-next-match -docstring 'Jump to the next grep match' %{
|
||||
# First jump to end of buffer so that if grep_current_line == 0
|
||||
# 0g<a-l> will be a no-op and we'll jump to the first result.
|
||||
# Yeah, thats ugly...
|
||||
execute-keys ge %opt{grep_current_line}g<a-l> /^[^:]+:\d+:<ret>
|
||||
execute-keys ge %opt{grep_current_line}g<a-l> /^[^:\n]+:\d+:<ret>
|
||||
grep-jump
|
||||
}
|
||||
try %{
|
||||
@ -83,7 +83,7 @@ define-command grep-previous-match -docstring 'Jump to the previous grep match'
|
||||
evaluate-commands -try-client %opt{jumpclient} %{
|
||||
buffer '*grep*'
|
||||
# See comment in grep-next-match
|
||||
execute-keys ge %opt{grep_current_line}g<a-h> <a-/>^[^:]+:\d+:<ret>
|
||||
execute-keys ge %opt{grep_current_line}g<a-h> <a-/>^[^:\n]+:\d+:<ret>
|
||||
grep-jump
|
||||
}
|
||||
try %{
|
||||
|
@ -56,7 +56,7 @@ define-command -hidden make-jump %{
|
||||
try %{
|
||||
execute-keys gl<a-?> "Entering directory" <ret><a-:>
|
||||
# Try to parse the error into capture groups, failing on absolute paths
|
||||
execute-keys s "Entering directory [`']([^']+)'.*\n([^:/][^:]*):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l
|
||||
execute-keys s "Entering directory [`']([^']+)'.*\n([^:\n/][^:\n]*):(\d+):(?:(\d+):)?([^\n]+)\z" <ret>l
|
||||
set-option buffer make_current_error_line %val{cursor_line}
|
||||
make-open-error "%reg{1}/%reg{2}" "%reg{3}" "%reg{4}" "%reg{5}"
|
||||
} catch %{
|
||||
|
Loading…
Reference in New Issue
Block a user