rc diff: pass diff to diff-jump via stdin instead of env
Passing large diff buffers via the environment can quickly result in the error "execve failed: Argument list too long". Use a pipe like in format.kak When running | (or <a-|>), Kakoune does not use %arg{@} to populate "$@" (missing feature?). Work around this by moving %arg{@} to a temporary register. Apparently $kak_quoted_reg_a will never be an empty list, so work around that too. When diff parsing fails, we take care to run "fail" in the calling client, unlike :format (probably a bug in format.kak). (This patch is best viewed while ignoring whitespace changes (diff -w))
This commit is contained in:
parent
eaaf562ed1
commit
13948ecb94
|
@ -27,7 +27,7 @@ define-command diff-jump -params .. -docstring %{
|
|||
- jump to the old file instead of the new file
|
||||
-<num> strip <num> leading directory components, like -p<num> in patch(1). Defaults to 1 if there is a 'diff' line (as printed by 'diff -r'), or 0 otherwise.
|
||||
} %{
|
||||
evaluate-commands -draft -save-regs c %{
|
||||
evaluate-commands -draft -save-regs ac| %{
|
||||
# Save the column because we will move the cursor.
|
||||
set-register c %val{cursor_column}
|
||||
# If there is a "diff" line, we don't need to look further back.
|
||||
|
@ -39,9 +39,10 @@ define-command diff-jump -params .. -docstring %{
|
|||
# or content.
|
||||
execute-keys Gk
|
||||
}
|
||||
evaluate-commands %sh{
|
||||
printf %s "$kak_selection" |
|
||||
column=$kak_reg_c perl -we '
|
||||
set-register a %arg{@}
|
||||
set-register | %{
|
||||
[ -n "$kak_reg_a" ] && eval set -- $kak_quoted_reg_a
|
||||
cmd=$(column=$kak_reg_c perl -we '
|
||||
sub quote {
|
||||
$SQ = "'\''";
|
||||
$token = shift;
|
||||
|
@ -51,7 +52,7 @@ define-command diff-jump -params .. -docstring %{
|
|||
sub fail {
|
||||
$reason = shift;
|
||||
print "fail " . quote("diff-jump: $reason");
|
||||
exit 1;
|
||||
exit;
|
||||
}
|
||||
$version = "+", $other_version = "-";
|
||||
$strip = undef;
|
||||
|
@ -138,12 +139,14 @@ define-command diff-jump -params .. -docstring %{
|
|||
}
|
||||
}
|
||||
|
||||
printf "set-register c %s $line $column", quote($file);
|
||||
' -- "$@"
|
||||
printf "edit -existing -- %s $line $column", quote($file);
|
||||
' -- "$@")
|
||||
echo "set-register c $cmd" >"$kak_command_fifo"
|
||||
}
|
||||
execute-keys <a-|><ret>
|
||||
evaluate-commands -client %val{client} %{
|
||||
evaluate-commands -try-client %opt{jumpclient} %{
|
||||
edit -existing -- %reg{c}
|
||||
%reg{c}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user