From 80298a95a064baac0d7fe68a2857fb41ac1a0a6e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 30 Aug 2016 23:23:33 +0100 Subject: [PATCH] clang.kak: Use two sed processes instead of one to avoid extra long pattern space The previous version was ending up with all the completion candidates in a single, multiline pattern space, regex substitution on it was extremely slow compared to the two process version where substitution is always running on a single candidate. --- rc/extra/clang.kak | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rc/extra/clang.kak b/rc/extra/clang.kak index ef540ca8f..5f1cd9ba0 100644 --- a/rc/extra/clang.kak +++ b/rc/extra/clang.kak @@ -63,8 +63,7 @@ def clang-parse -params 0..1 -docstring "Parse the contents of the current buffe docstrings[id]=desc } END { - for (id in docstrings) - { + for (id in docstrings) { menu=id gsub(/(^|[^[:alnum:]_])(operator|new|delete)($|[^[:alnum:]_])/, "{keyword}&{}", menu) gsub(/(^|[[:space:]])(int|size_t|bool|char|unsigned|signed|long)($|[[:space:]])/, "{type}&{}", menu) @@ -102,7 +101,7 @@ def -hidden clang-show-completion-info %[ try %[ eval -draft %[ exec {( ^\( b \`\w+\' %sh[ - desc=$(printf %s\\n "${kak_opt_clang_completions}" | sed -ne "{ s/\([^\\]\):/\1\n/g }; /^${kak_selection}|/ { s/^[^|]\+|//; s/|.*$//; s/\\\:/:/g; P }; D") + desc=$(printf %s\\n "${kak_opt_clang_completions}" | sed -e "{ s/\([^\\]\):/\1\n/g }" | sed -ne "/^${kak_selection}|/ { s/^[^|]\+|//; s/|.*$//; s/\\\:/:/g; p }") if [ -n "$desc" ]; then printf %s\\n "eval -client $kak_client %{info -anchor ${kak_cursor_line}.${kak_cursor_column} -placement above %{${desc}}}" fi