summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Bielik <mx.bielik@gmail.com>2023-04-19 19:41:30 +0200
committerMartin Bielik <mx.bielik@gmail.com>2023-04-19 19:41:30 +0200
commitec53d91e7f54cb363b4e68a7ed3f03fca8704902 (patch)
tree02186ed2d65fea12ce0ebc40137c7afc6aacdb77
parentf1697631eb8652bd676aaa7c3cb86dbe44ac4323 (diff)
downloadvim-ai-ec53d91e7f54cb363b4e68a7ed3f03fca8704902.tar.gz
use selection block only if it is safe
-rw-r--r--autoload/vim_ai.vim8
1 files 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