From 49d579da98018af990a7195a544d514fb2f41aeb Mon Sep 17 00:00:00 2001 From: jamesb6626 Date: Sat, 7 Jun 2025 18:02:55 +0100 Subject: [PATCH] llama.vim: add code to reduce suffix duplication A perfect llm wouldn't need this, but if the suffix is already there we should avoid appending it again, particularly in multi-line suggestions. Except closing brackets or similar. We should still append those. --- autoload/llama.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/autoload/llama.vim b/autoload/llama.vim index 619861f..bfd85e2 100644 --- a/autoload/llama.vim +++ b/autoload/llama.vim @@ -914,7 +914,13 @@ function! s:fim_render(pos_x, pos_y, data) " endif "endfor - let l:content[-1] .= l:line_cur_suffix + " only add suffix if not already there to workaround confused llms, + " only match if word chars are in the suffix to avoid miscounting brackets + " or other important punctuation from correct llm output, + " may need tweaking if a bad pattern comes up + if !(l:content[-1] =~# '\V' . escape(l:line_cur_suffix, '/\') . '\$' && l:line_cur_suffix =~# '\w\w' ) + let l:content[-1] .= l:line_cur_suffix + endif " if only whitespaces - do not accept if join(l:content, "\n") =~? '^\s*$'