≡

wincent.dev

  • Products
  • Blog
  • Wiki
  • Issues
You are viewing an historical archive of past issues. Please report new issues to the appropriate project issue tracker on GitHub.
Home » Issues » Bug #1733

Bug #1733: Closing Command-T window with Ctrl-W q leaves the cursor invisible and breaks Command-T.

Kind bug
Product Command-T
When Created 2010-11-11T00:08:23Z, updated 2010-12-03T16:03:52Z
Status closed
Reporter Marius Gedminas
Tags no tags

Description

  • Start gvim
  • Press \t
  • Press Ctrl-W
  • Press q

Now you can't see where your cursor is. (This doesn't happen in terminal vim)

  • Press \t again

Nothing happens. I'd expect Command-T to open again. This affects both gvim and vim.

Comments

  1. Marius Gedminas 2010-11-11T00:10:15Z

    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.

  2. Greg Hurrell 2010-11-11T07:35:19Z

    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 either ESC or Ctrl-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.)

  3. Greg Hurrell 2010-11-27T10:28:14Z

    Marked ticket #1745 as a duplicate of this one.

  4. Greg Hurrell 2010-11-27T11:01:52Z

    I'm going to see if I can refactor the cleanup so that it is triggered by an autocmd (BufUnload or BufWipetout 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.

  5. Greg Hurrell 2010-11-27T11:40:31Z

    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
  6. Greg Hurrell 2010-11-27T17:53:32Z

    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.

  7. Greg Hurrell 2010-12-03T16:03:46Z

    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).

  8. Greg Hurrell 2010-12-03T16:03:52Z

    Status changed:

    • From: new
    • To: closed
Add a comment

Comments are now closed for this issue.

  • contact
  • legal

Menu

  • Blog
  • Wiki
  • Issues
  • Snippets