Skip to content

Commit

Permalink
Merge branch 'pull/315'
Browse files Browse the repository at this point in the history
Closes: #315

* pull/315:
  doc: update AUTHORS and HISTORY
  Fix GotoOrOpen command
  • Loading branch information
wincent committed Nov 17, 2017
2 parents c5882de + 02cd5ef commit 7147ba9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 36 deletions.
28 changes: 20 additions & 8 deletions autoload/commandt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,34 @@ function! commandt#CheckBuffer(buffer_number) abort
endif
endfunction

function! s:BufHidden(buffer)
" visible == exists, loaded, listed and not hidden
" (buffer is opened in a window - in current or another tab)
function! s:BufVisible(buffer)
" buffer is opened in current tab (quick check for current tab)
if bufwinnr('^' . a:buffer . '$') != -1 | return 1 | end
" buffer exists if it has been opened at least once (unless wiped)
if !bufexists(a:buffer) | return 0 | end
" buffer is not loaded when its last window is closed (`set nohidden` only)
if !bufloaded(a:buffer) | return 0 | end
" buffer is not listed when it's deleted
if !buflisted(a:buffer) | return 0 | end

let bufno = bufnr(a:buffer)
let listed_buffers = ''
let ls_buffers = ''

redir => listed_buffers
redir => ls_buffers
silent ls
redir END

for line in split(listed_buffers, "\n")
" buffer is hidden when its last window is closed (`set hidden` only)
for line in split(ls_buffers, "\n")
let components = split(line)
if components[0] == bufno
return match(components[1], 'h') != -1
return match(components[1], 'h') == -1
endif
endfor
return 0

return 1
endfunction

function! commandt#GotoOrOpen(command_and_args) abort
Expand All @@ -164,8 +177,7 @@ function! commandt#GotoOrOpen(command_and_args) abort
" `bufwinnr()` doesn't see windows in other tabs, meaning we open them again
" instead of switching to the other tab; but `bufname()` sees hidden
" buffers, and if we try to open one of those, we get an unwanted split.
if bufwinnr('^' . l:file . '$') != -1 ||
\ (bufname('^' . l:file . '$') !=# '' && !s:BufHidden(l:file))
if s:BufVisible(l:file)
execute 'sbuffer ' . l:file
else
execute l:command . l:file
Expand Down
58 changes: 30 additions & 28 deletions doc/command-t.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1400,34 +1400,35 @@ Other contributors that have submitted patches include, in alphabetical order:
Abhinav Gupta Nicholas T.
Adrian Keet Nicolas Alpi
Aleksandrs Ļedovskis Nikolai Aleksandrovich Pavlov
Andy Waite Nilo César Teixeira
Anthony Panozzo Noon Silk
Artem Nezvigin Ole Petter Bang
Ben Boeckel Patrick Hayes
Daniel Burgess Paul Jolly
Daniel Hahler Pavel Sergeev
David Szotten Rainux Luo
Douglas Drumond Richard Feldman
Emily Strickland Roland Puntaier
Felix Tjandrawibawa Ross Lagerwall
Gary Bernhardt Sam Morris
Henric Trotzig Scott Bronson
Ivan Ukhov Seth Fowler
Jakob Pfender Sherzod Gapirov
Jeff Kreeftmeijer Shlomi Fish
Jerome Castaneda Stefan Schmidt
Joe Lencioni Stephen Gelman
KJ Tsanaktsidis Steven Moazami
Kevin Webster Steven Stallion
Kien Nguyen Duc Sung Pae
Lucas de Vries Thomas Pelletier
Marcus Brito Ton van den Heuvel
Marian Schubert Victor Hugo Borja
Matthew Todd Vlad Seghete
Max Timkovich Vít Ondruch
Mike Lundy Woody Peterson
Nadav Samet Yan Pritzker
Nate Kane Zak Johnson
Alexey Terekhov Nilo César Teixeira
Andy Waite Noon Silk
Anthony Panozzo Ole Petter Bang
Artem Nezvigin Patrick Hayes
Ben Boeckel Paul Jolly
Daniel Burgess Pavel Sergeev
Daniel Hahler Rainux Luo
David Szotten Richard Feldman
Douglas Drumond Roland Puntaier
Emily Strickland Ross Lagerwall
Felix Tjandrawibawa Sam Morris
Gary Bernhardt Scott Bronson
Henric Trotzig Seth Fowler
Ivan Ukhov Sherzod Gapirov
Jakob Pfender Shlomi Fish
Jeff Kreeftmeijer Stefan Schmidt
Jerome Castaneda Stephen Gelman
Joe Lencioni Steven Moazami
KJ Tsanaktsidis Steven Stallion
Kevin Webster Sung Pae
Kien Nguyen Duc Thomas Pelletier
Lucas de Vries Ton van den Heuvel
Marcus Brito Victor Hugo Borja
Marian Schubert Vlad Seghete
Matthew Todd Vít Ondruch
Max Timkovich Woody Peterson
Mike Lundy Yan Pritzker
Nadav Samet Zak Johnson
Nate Kane

This list produced with:

Expand Down Expand Up @@ -1556,6 +1557,7 @@ HISTORY *command-t-history*
master (not yet released) ~

- Fix unlisted buffers showing up in |:CommandTBuffer| listing on Neovim.
- Fix edge cases with opening selections in tabs (#315).

5.0.2 (7 September 2017) ~

Expand Down

0 comments on commit 7147ba9

Please sign in to comment.