Comments
-
Marius Gedminas
Hm, actually this breaks more than I though. Command-T appears to be active, but with its window invisible, so I cannot edit my text.
-
Greg Hurrell
Thanks for the report. I'll see if I can suppress this behavior.
One question, though: why are you trying to do
Ctrl-W q
when in the Command-T window? The documented way to dismiss the window is eitherESC
orCtrl-C
, or you can set your own mapping up if you don't like either of those (see the docs for how).(The reason why you're seeing this bug is that when you blow away the window with
Ctrl-W q
, you're bypassing all the normal clean-up that Command-T would normally do to dispose of itself.) -
Greg Hurrell
Marked ticket #1745 as a duplicate of this one.
-
Greg Hurrell
I'm going to see if I can refactor the cleanup so that it is triggered by an autocmd (
BufUnload
orBufWipetout
etc) rather than explicitly in response to a user using one of the documented methods for closing the Command-T window. This way it should run no matter how the window is disposed of or exited.Sure, it would be simpler to add a special case to catch
Ctrl-W q
, but it will probably only be a matter of time until someone reports another special case, and another, and another... Would prefer to come up with a catch-all solution now. -
Greg Hurrell
Ok, here's a patch which I am playing around with now which implements the autocmd-based cleanup.
Definitely works in the case of
<C-W q>
, although not yet for<C-W k>
(seeing as in the later case we're only doing part of the cleanup, and not actually removing the buffer). May need to add a separate autocmd to handle the leaving case differently.diff --git a/plugin/command-t.vim b/plugin/command-t.vim index 716a889..dc2c1c9 100644 --- a/plugin/command-t.vim +++ b/plugin/command-t.vim @@ -125,6 +125,10 @@ function CommandTCursorStart() ruby $command_t.cursor_start endfunction +function CommandTCleanup() + ruby $command_t.cleanup +endfunction + ruby << EOF # require Ruby files begin diff --git a/ruby/command-t/controller.rb b/ruby/command-t/controller.rb index 9d45897..ef81a35 100644 --- a/ruby/command-t/controller.rb +++ b/ruby/command-t/controller.rb @@ -138,6 +138,10 @@ module CommandT @prompt.cursor_start if @focus == @prompt end + def cleanup + @match_window.cleanup + end + private def set_up_max_height diff --git a/ruby/command-t/match_window.rb b/ruby/command-t/match_window.rb index 7311d89..9279b2a 100644 --- a/ruby/command-t/match_window.rb +++ b/ruby/command-t/match_window.rb @@ -79,7 +79,7 @@ module CommandT ].each { |command| ::VIM::command command } # sanity check: make sure the buffer really was created - raise "Can't find GoToFile buffer" unless $curbuf.name.match /GoToFile/ + raise "Can't find GoToFile buffer" unless $curbuf.name.match /GoToFile\z/ @@buffer = $curbuf end @@ -97,6 +97,13 @@ module CommandT hide_cursor end + # perform cleanup using an autocmd to ensure we don't get caught out + # by some unexpected means of dismissing or leaving the Command-T window + # (eg. <C-W q>, <C-W k> etc) + ::VIM::command 'augroup CommandT' + ::VIM::command 'autocmd!' + ::VIM::command 'autocmd BufLeave GoToFile call CommandTCleanup()' + ::VIM::command 'augroup end' @has_focus = false @selection = nil @@ -120,6 +127,9 @@ module CommandT else ::VIM::command "bunload! #{@@buffer.number}" end + end + + def cleanup restore_window_dimensions @settings.restore @prompt.dispose
-
Greg Hurrell
Have pushed a few commits here:
- https://wincent.dev/repos/command-t/commits/80277295f4a7072d8817bd615fc4b2d84e41ee93
- https://wincent.dev/repos/command-t/commits/0976b17796cda059a60f1e7ae5bd7ea6ffc2f1a7
- https://wincent.dev/repos/command-t/commits/3a8ad5b46ce2c2ee9561d7587b24a1f90cf51396
As that last commit message states, not sure why the "BufUnload" event isn't triggered when I do a manual close in response to a "BufLeave" (eg. the
<C-W k>
case), but the observable behavior, at least, is correct. -
Greg Hurrell
I've been using Vim the last few days with the above patches applied and haven't discovered any weirdness, so going to mark this one as closed.
The changes will be included in the next release (not sure whether it will be 1.0.1 or 1.1 yet).
-
Greg Hurrell
Status changed:
- From: new
- To: closed
Add a comment
Comments are now closed for this issue.