rc lint: Adapt to upstream changes in the format of string lists

This commit is contained in:
Frank LENORMAND 2018-07-18 15:48:34 +03:00
parent 4612d0928a
commit 6f35f41ba0

View File

@ -104,42 +104,52 @@ define-command lint-disable -docstring "Disable automatic diagnostics of the cod
define-command lint-next-error -docstring "Jump to the next line that contains an error" %{ define-command lint-next-error -docstring "Jump to the next line that contains an error" %{
update-option buffer lint_errors update-option buffer lint_errors
evaluate-commands %sh{ evaluate-commands %sh{
printf '%s\n' "$kak_opt_lint_errors" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | { eval "set -- ${kak_opt_lint_errors}"
while IFS='|' read -r candidate rest shift
do
first_range=${first_range-$candidate} for i in "$@"; do
if [ "${candidate%%.*}" -gt "$kak_cursor_line" ]; then candidate="${i%%|*}"
range=$candidate if [ "${candidate%%.*}" -gt "${kak_cursor_line}" ]; then
break range="${candidate}"
fi break
done
range=${range-$first_range}
if [ -n "$range" ]; then
printf '%s\n' "select $range"
else
printf 'echo -markup "{Error}no lint diagnostics"\n'
fi fi
} done
}}
range="${range-${1%%|*}}"
if [ -n "${range}" ]; then
printf 'select %s\n' "${range}"
else
printf 'echo -markup "{Error}no lint diagnostics"\n'
fi
}
}
define-command lint-previous-error -docstring "Jump to the previous line that contains an error" %{ define-command lint-previous-error -docstring "Jump to the previous line that contains an error" %{
update-option buffer lint_errors update-option buffer lint_errors
evaluate-commands %sh{ evaluate-commands %sh{
printf '%s\n' "$kak_opt_lint_errors" | sed -e 's/\([^\\]\):/\1\n/g' | tail -n +2 | sort -t. -k1,1 -rn | { eval "set -- ${kak_opt_lint_errors}"
while IFS='|' read -r candidate rest shift
do
first_range=${first_range-$candidate} for i in "$@"; do
if [ "${candidate%%.*}" -lt "$kak_cursor_line" ]; then candidate="${i%%|*}"
range=$candidate
break if [ "${candidate%%.*}" -ge "${kak_cursor_line}" ]; then
fi range="${last_candidate}"
done break
range=${range-$first_range}
if [ -n "$range" ]; then
printf '%s\n' "select $range"
else
printf 'echo -markup "{Error}no lint diagnostics"\n'
fi fi
}
}} last_candidate="${candidate}"
done
if [ $# -ge 1 ]; then
shift $(($# - 1))
range="${range:-${1%%|*}}"
printf 'select %s\n' "${range}"
else
printf 'echo -markup "{Error}no lint diagnostics"\n'
fi
}
}