Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Proper handling of the lack of current buffer

  • Loading branch information...
commit 6a3737666f62b93bb6081a0cc6cedc77d9ea1e8f 1 parent de062f1
@adaszko authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 autoload/chbuf.vim
View
12 autoload/chbuf.vim
@@ -27,8 +27,12 @@ function! BufferFromNumber(number, name, score) " {{{
return {'number': a:number, 'name': a:name, 'score': a:score, 'basename': split(a:name, s:directory_separator)[-1], 'switch': function('SwitchToNumber')}
endfunction " }}}
-function! CurrentBuffer() " {{{
- return BufferFromNumber(bufnr('%'), bufname('%'), 0)
+function! Nop() dict " {{{
+
+endfunction " }}}
+
+function! DummyBuffer() " {{{
+ return {'switch': function('Nop')}
endfunction " }}}
function! SwitchToPath() dict " {{{
@@ -113,14 +117,14 @@ function! BufferNameCallback(input) " {{{
let buffers = FilterBuffersMatching(a:input, GetSortedBuffers())
if len(buffers) == 0
- return [CurrentBuffer(), '']
+ return [DummyBuffer(), '']
endif
return [buffers[0], MakeChoicesString(buffers)]
endfunction " }}}
function! PromptBuffer() " {{{
- return getline#GetLine(s:prompt_string, 'BufferNameCallback', CurrentBuffer())
+ return getline#GetLine(s:prompt_string, 'BufferNameCallback', DummyBuffer())
endfunction " }}}
function! chbuf#SwitchBuffer() " {{{
Please sign in to comment.
Something went wrong with that request. Please try again.