From ec53d91e7f54cb363b4e68a7ed3f03fca8704902 Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Wed, 19 Apr 2023 19:41:30 +0200 Subject: use selection block only if it is safe --- autoload/vim_ai.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/autoload/vim_ai.vim b/autoload/vim_ai.vim index ac79f3b..00792dd 100644 --- a/autoload/vim_ai.vim +++ b/autoload/vim_ai.vim @@ -52,9 +52,13 @@ function! s:MakePrompt(is_selection, lines, instruction) if l:instruction == "" let l:selection = l:lines elseif a:is_selection - " TODO: check if lines already contain ##### " NOTE: surround selection with ##### in order to eliminate empty responses - let l:selection = "#####\n" . l:lines . "\n#####" + " TODO: add selection prompt boundary config + if match(l:lines, "#####") != -1 + let l:selection = l:lines + else + let l:selection = "#####\n" . l:lines . "\n#####" + endif endif return join([l:instruction, l:delimiter, l:selection], "") endfunction -- cgit v1.2.3