aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundle/prr-ui/autoload/prr_ui.vim59
-rw-r--r--bundle/prr-ui/ftplugin/prr/prr_ui.vim7
-rw-r--r--bundle/prr-ui/plugin/prr_ui.vim2
3 files changed, 56 insertions, 12 deletions
diff --git a/bundle/prr-ui/autoload/prr_ui.vim b/bundle/prr-ui/autoload/prr_ui.vim
index c4e2afa..7b152b7 100644
--- a/bundle/prr-ui/autoload/prr_ui.vim
+++ b/bundle/prr-ui/autoload/prr_ui.vim
@@ -885,6 +885,55 @@ endfunction
function! prr_ui#Comment()
let current_line = getline('.')
+ call prr_ui#SplitPrrBuffer()
+
+ call search(current_line)
+
+ " Put the cursor in place to add a comment on the line.
+ call append('.', ['', '', ''])
+ call cursor(line('.') + 2, 0)
+
+ startinsert
+endfunction
+
+
+function! prr_ui#Approve()
+ " If current buffer is not prr, then PrrStart.
+ if !prr_ui#IsCurrentBufferPrr()
+ call prr_ui#SplitPrrBuffer()
+ endif
+
+ call append(
+ \ 0,
+ \ [
+ \ 'Looks good ' . prr_ui#RandomEmoji(),
+ \ '',
+ \ '@prr approve',
+ \ ''
+ \ ]
+ \ )
+ call cursor(1, 0)
+endfunction
+
+function! prr_ui#Reject()
+ if !prr_ui#IsCurrentBufferPrr()
+ call prr_ui#SplitPrrBuffer()
+ endif
+
+ call append(
+ \ 0,
+ \ [
+ \ '',
+ \ '',
+ \ '@prr reject',
+ \ ''
+ \ ]
+ \ )
+ call cursor(1, 0)
+endfunction
+
+
+function! prr_ui#SplitPrrBuffer()
try
" Open the existing Prr review file in a new split.
sbuffer prr
@@ -893,11 +942,11 @@ function! prr_ui#Comment()
execute 'split ' . prr_path
endtry
- call search(current_line)
+endfunction
- " Put the cursor in place to add a comment on the line.
- call append('.', ['', '', ''])
- call cursor(line('.') + 2, 0)
+function! prr_ui#IsCurrentBufferPrr()
+ let current_buffer_name = bufname()
+ let pos = match(current_buffer_name, '\.prr$')
- startinsert
+ return pos != -1
endfunction
diff --git a/bundle/prr-ui/ftplugin/prr/prr_ui.vim b/bundle/prr-ui/ftplugin/prr/prr_ui.vim
index 09e02d2..679d0fa 100644
--- a/bundle/prr-ui/ftplugin/prr/prr_ui.vim
+++ b/bundle/prr-ui/ftplugin/prr/prr_ui.vim
@@ -1,12 +1,5 @@
let b:undo_ftplugin = ''
-command! -buffer PrrApprove
- \ normal! ggOLooks good <C-r>=prr_ui#RandomEmoji()<CR><CR><CR>@prr approve<CR><Esc>gg
-command! -buffer PrrReject normal! ggO<CR><CR>@prr reject<CR><Esc>gg
-
-let b:undo_ftplugin .= '| delcommand -buffer PrrApprove'
-let b:undo_ftplugin .= '| delcommand -buffer PrrReject'
-
" Educate quotes.
if !exists('b:textobj_quote_educate_mapped')
\ || b:textobj_quote_educate_mapped == 0
diff --git a/bundle/prr-ui/plugin/prr_ui.vim b/bundle/prr-ui/plugin/prr_ui.vim
index 665f65b..74fc1ba 100644
--- a/bundle/prr-ui/plugin/prr_ui.vim
+++ b/bundle/prr-ui/plugin/prr_ui.vim
@@ -6,3 +6,5 @@ let g:loaded_prr_ui = 1
command! PrrStart call prr_ui#StartInteractive()
command! PrrSubmit call prr_ui#Submit()
command! PrrComment call prr_ui#Comment()
+command! PrrApprove call prr_ui#Approve()
+command! PrrReject call prr_ui#Reject()