From 535438951f95908c7dcce1313797d848d3453669 Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Wed, 19 Sep 2018 22:50:07 +0200 Subject: [PATCH] Guard against wiped-out match listing buffer in Neovim 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: https://github.com/wincent/command-t/issues/342 Thanks to Javier Parra for the bug report with a minimal repro recipe and diagnosis of the problem. --- doc/command-t.txt | 1 + ruby/command-t/lib/command-t/match_window.rb | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/command-t.txt b/doc/command-t.txt index 67e6dc92..af4d465a 100644 --- a/doc/command-t.txt +++ b/doc/command-t.txt @@ -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) ~ diff --git a/ruby/command-t/lib/command-t/match_window.rb b/ruby/command-t/lib/command-t/match_window.rb index 87b39e90..1c07383c 100644 --- a/ruby/command-t/lib/command-t/match_window.rb +++ b/ruby/command-t/lib/command-t/match_window.rb @@ -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