Skip to content

Commit

Permalink
Guard against wiped-out match listing buffer in Neovim
Browse files Browse the repository at this point in the history
If somebody deletes the Command-T match listing buffer on Neovim (eg.
with `:bwipeout`), Command-T will blow up on the next invocation because
Neovim doesn't define `Vim::DeletedBufferError`.

Closes: #342

Thanks to Javier Parra for the bug report with a minimal repro recipe
and diagnosis of the problem.
  • Loading branch information
wincent committed Sep 19, 2018
1 parent 3e54b4a commit 5354389
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/command-t.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,7 @@ next (not yet released) ~
- Fix edge cases with opening selections in tabs (#315).
- Fix possible degenerate performance of |:CommandTBuffer| and
|:CommandTMRU| on Neovim.
- Handle missing match listing buffer in Neovim (#342).

5.0.2 (7 September 2017) ~

Expand Down
13 changes: 10 additions & 3 deletions ruby/command-t/lib/command-t/match_window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,16 @@ def initialize(options = {})

def buffer_number
@@buffer && @@buffer.number
rescue Vim::DeletedBufferError
# Beware of people manually deleting Command-T's hidden, unlisted buffer.
@@buffer = nil
rescue StandardError => e
if (
defined?(Vim::DeletedBufferError) && e.instance_of?(Vim::DeletedBufferError) ||
e.message =~ /Invalid buffer/
)
# Something/someone deleted Command-T's hidden, unlisted buffer.
@@buffer = nil
else
raise
end
end

def close
Expand Down

0 comments on commit 5354389

Please sign in to comment.