Skip to content

Commit

Permalink
Load the config before viewing a prompt
Browse files Browse the repository at this point in the history
Lazy-load the Neural config before viewing a prompt, and update tests
to reset state better.
  • Loading branch information
w0rp committed Jun 2, 2024
1 parent db8b774 commit f53af00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions autoload/neural.vim
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ endfunction

" Print the prompt that Neural will use in full.
function! neural#ViewPrompt(...) abort
" Reload the Neural config on a prompt request if needed.
call neural#config#Load()

" Take the first argument or nothing.
let l:prompt = get(a:000, 0, '')
let l:buffer = bufnr('')
Expand Down
3 changes: 3 additions & 0 deletions test/vim/test_buffer.vader
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ Before:
call add(g:calls, ['neural#Run', a:prompt, a:options])
endfunction

let g:output = ''

After:
unlet! g:calls
unlet! g:output

runtime autoload/neural/job.vim

Expand Down
8 changes: 8 additions & 0 deletions test/vim/test_view_prompt.vader
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Before:
Save g:neural

unlet! g:neural
let g:output = ''

After:
Restore

unlet! g:output

Given markdown(An empty Markdown file):
Expand Down

0 comments on commit f53af00

Please sign in to comment.