Merge remote-tracking branch 'krobelus/fix-git-blame'
This commit is contained in:
commit
8e2eacae83
|
@ -138,34 +138,35 @@ define-command -params 1.. \
|
||||||
try %{ add-highlighter window/git-blame flag-lines Information git_blame_flags }
|
try %{ add-highlighter window/git-blame flag-lines Information git_blame_flags }
|
||||||
set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp'
|
set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp'
|
||||||
}" | kak -p ${kak_session}
|
}" | kak -p ${kak_session}
|
||||||
git blame "$@" --incremental ${kak_buffile} | awk '
|
git blame "$@" --incremental ${kak_buffile} | perl -wne '
|
||||||
function send_flags(flush, text, i) {
|
use POSIX qw(strftime);
|
||||||
if (line == "") { return; }
|
sub send_flags {
|
||||||
text=substr(sha,1,8) " " dates[sha] " " authors[sha]
|
my $flush = shift;
|
||||||
# gsub("|", "\\|", text)
|
if (not defined $line) { return; }
|
||||||
gsub("~", "~~", text)
|
my $text = substr($sha,1,8) . " " . $dates{$sha} . " " . $authors{$sha};
|
||||||
for ( i=0; i < count; i++ ) {
|
$text =~ s/~/~~/g;
|
||||||
flags = flags " %~" line+i "|" text "~"
|
for ( my $i = 0; $i < $count; $i++ ) {
|
||||||
|
$flags .= " %~" . ($line+$i) . "|$text~";
|
||||||
}
|
}
|
||||||
now = systime()
|
$now = time();
|
||||||
# Send roughly one update per second, to avoid creating too many kak processes.
|
# Send roughly one update per second, to avoid creating too many kak processes.
|
||||||
if (!flush && now - last_sent < 1) {
|
if (!$flush && defined $last_sent && $now - $last_sent < 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cmd = "kak -p " ENVIRON["kak_session"]
|
open CMD, "|-", "kak -p $ENV{kak_session}";
|
||||||
print "set-option -add buffer=" ENVIRON["kak_bufname"] " git_blame_flags " flags | cmd
|
print CMD "set-option -add buffer=$ENV{kak_bufname} git_blame_flags $flags";
|
||||||
close(cmd)
|
close(CMD);
|
||||||
flags = ""
|
$flags = "";
|
||||||
last_sent = now
|
$last_sent = $now;
|
||||||
}
|
}
|
||||||
/^([0-9a-f]+) ([0-9]+) ([0-9]+) ([0-9]+)/ {
|
if (m/^([0-9a-f]+) ([0-9]+) ([0-9]+) ([0-9]+)/) {
|
||||||
send_flags(0)
|
send_flags(0);
|
||||||
sha=$1
|
$sha = $1;
|
||||||
line=$3
|
$line = $3;
|
||||||
count=$4
|
$count = $4;
|
||||||
}
|
}
|
||||||
/^author / { authors[sha]=substr($0,8) }
|
if (m/^author /) { $authors{$sha} = substr($_,7) }
|
||||||
/^author-time ([0-9]*)/ { dates[sha]=strftime("%F %T", $2) }
|
if (m/^author-time ([0-9]*)/) { $dates{$sha} = strftime("%F %T", localtime $1) }
|
||||||
END { send_flags(1); }'
|
END { send_flags(1); }'
|
||||||
) > /dev/null 2>&1 < /dev/null &
|
) > /dev/null 2>&1 < /dev/null &
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user