≡

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 » Feature request #1517

Feature request #1517: add MaxHeight option to allow the user to limit the command-t window expansion (patch included)

Kind feature request
Product Command-T
When 2010-03-24T15:40:21Z
Status closed
Reporter Lucas de Vries
Tags no tags

Description

Since I didn't like it that in folders with lots of files, Command-T would take over the entire screen, I added an option that can limit it. If you're interested, the patch is:

 From 460f2b28c28e42a2471e384b71c89409643d304c Mon Sep 17 00:00:00 2001
 From: Lucas de Vries <lucas@glacicle.org>
 Date: Wed, 24 Mar 2010 20:28:44 +0000
 Subject: [PATCH] add g:CommandTMaxHeight option to limit window height
 
 ---
  doc/command-t.txt            |    7 +++++++
  ruby/command-t/controller.rb |    6 ++++--
  2 files changed, 11 insertions(+), 2 deletions(-)
 
 diff --git a/doc/command-t.txt b/doc/command-t.txt
 index 3795f8f..28ac935 100644
 --- a/doc/command-t.txt
 +++ b/doc/command-t.txt
 @@ -212,6 +212,13 @@ Following is a list of all available options:
        current directory. Any directories at levels beyond this depth will be
        skipped.
  
 +                                                *command-t-max-height*
 +  |g:CommandTMaxHeight|                           number (default 0)
 +
 +      The maximum height the Command-T window is allowed to expand to. If set
 +      to 0, the window will expand to the entire vim height when it contains
 +      enough entries.
 +
                                                  *command-t-always-show-dot-files*
    |g:CommandTAlwaysShowDotFiles|                 boolean (default: 0)
  
 diff --git a/ruby/command-t/controller.rb b/ruby/command-t/controller.rb
 index 5f73081..e2969ae 100644
 --- a/ruby/command-t/controller.rb
 +++ b/ruby/command-t/controller.rb
 @@ -25,6 +25,8 @@ module CommandT
    class Controller
      def initialize
        @prompt = Prompt.new
 +      @max_height = get_number('g:CommandTMaxHeight')
 +      @max_height = @max_height.nil? ? 0 : @max_height.to_i
        @scanner = CommandT::Base.new nil,
          :max_files              => get_number('g:CommandTMaxFiles'),
          :max_depth              => get_number('g:CommandTMaxDepth'),
 @@ -201,9 +203,9 @@ module CommandT
      end
  
      # Returns the desired maximum number of matches, based on available
 -    # vertical space.
 +    # vertical space and the max_height option.
      def match_limit
 -      limit = VIM::Screen.lines - 5
 +      limit = [VIM::Screen.lines - 5, @max_height].min
        limit < 0 ? 1 : limit
      end
  
 -- 
 1.7.0.2
 

Comments

  1. Lucas de Vries 2010-03-24T16:22:04Z

    Sorry about that, there's a bug in there, it does not work correctly when max_height is zero. This patch should work:

    From e4cd8bf78ae7c3ebbae043c124954a5ae4b731b1 Mon Sep 17 00:00:00 2001
    From: Lucas de Vries <lucas@glacicle.org>
    Date: Wed, 24 Mar 2010 21:20:03 +0000
    Subject: [PATCH] add g:CommandTMaxHeight option to limit window height
    
    ---
     doc/command-t.txt            |    7 +++++++
     ruby/command-t/controller.rb |    4 +++-
     2 files changed, 10 insertions(+), 1 deletions(-)
    
    diff --git a/doc/command-t.txt b/doc/command-t.txt
    index 3795f8f..28ac935 100644
    --- a/doc/command-t.txt
    +++ b/doc/command-t.txt
    @@ -212,6 +212,13 @@ Following is a list of all available options:
           current directory. Any directories at levels beyond this depth will be
           skipped.
     
    +                                                *command-t-max-height*
    +  |g:CommandTMaxHeight|                           number (default 0)
    +
    +      The maximum height the Command-T window is allowed to expand to. If set
    +      to 0, the window will expand to the entire vim height when it contains
    +      enough entries.
    +
                                                     *command-t-always-show-dot-files*
       |g:CommandTAlwaysShowDotFiles|                 boolean (default: 0)
     
    diff --git a/ruby/command-t/controller.rb b/ruby/command-t/controller.rb
    index 5f73081..8234df5 100644
    --- a/ruby/command-t/controller.rb
    +++ b/ruby/command-t/controller.rb
    @@ -25,6 +25,7 @@ module CommandT
       class Controller
         def initialize
           @prompt = Prompt.new
    +      @max_height = get_number('g:CommandTMaxHeight')
           @scanner = CommandT::Base.new nil,
             :max_files              => get_number('g:CommandTMaxFiles'),
             :max_depth              => get_number('g:CommandTMaxDepth'),
    @@ -201,9 +202,10 @@ module CommandT
         end
     
         # Returns the desired maximum number of matches, based on available
    -    # vertical space.
    +    # vertical space and the max_height option.
         def match_limit
           limit = VIM::Screen.lines - 5
    +      limit = @max_height.nil? ? limit : [limit, @max_height.to_i].min
           limit < 0 ? 1 : limit
         end
     
    -- 
    1.7.0.3
    
  2. Lucas de Vries 2010-03-24T16:32:54Z

    Gah! This place really needs an edit button. I missed yet another case (manually setting MaxHeight to 0) Let's hope I got it right this time ;)

    From 932f88bc1bfa6e3476916ad1e528647a39213cc1 Mon Sep 17 00:00:00 2001
    From: Lucas de Vries <lucas@glacicle.org>
    Date: Wed, 24 Mar 2010 21:31:29 +0000
    Subject: [PATCH] add g:CommandTMaxHeight option to limit window height
    
    ---
     doc/command-t.txt            |    7 +++++++
     ruby/command-t/controller.rb |    5 ++++-
     2 files changed, 11 insertions(+), 1 deletions(-)
    
    diff --git a/doc/command-t.txt b/doc/command-t.txt
    index 3795f8f..ef3b6e1 100644
    --- a/doc/command-t.txt
    +++ b/doc/command-t.txt
    @@ -212,6 +212,13 @@ Following is a list of all available options:
           current directory. Any directories at levels beyond this depth will be
           skipped.
     
    +                                                *command-t-max-height*
    +  |g:CommandTMaxHeight|                           number (default: 0)
    +
    +      The maximum height the Command-T window is allowed to expand to. If set
    +      to 0, the window will expand to the entire vim height when it contains
    +      enough entries.
    +
                                                     *command-t-always-show-dot-files*
       |g:CommandTAlwaysShowDotFiles|                 boolean (default: 0)
     
    diff --git a/ruby/command-t/controller.rb b/ruby/command-t/controller.rb
    index 5f73081..f2d5ba7 100644
    --- a/ruby/command-t/controller.rb
    +++ b/ruby/command-t/controller.rb
    @@ -25,6 +25,8 @@ module CommandT
       class Controller
         def initialize
           @prompt = Prompt.new
    +      @max_height = get_number('g:CommandTMaxHeight')
    +      @max_height = @max_height.nil? ? 0 : @max_height.to_i
           @scanner = CommandT::Base.new nil,
             :max_files              => get_number('g:CommandTMaxFiles'),
             :max_depth              => get_number('g:CommandTMaxDepth'),
    @@ -201,9 +203,10 @@ module CommandT
         end
     
         # Returns the desired maximum number of matches, based on available
    -    # vertical space.
    +    # vertical space and the max_height option.
         def match_limit
           limit = VIM::Screen.lines - 5
    +      limit = @max_height <= 0 ? limit : [limit, @max_height].min
           limit < 0 ? 1 : limit
         end
     
    -- 
    1.7.0.3
    
  3. Greg Hurrell 2010-03-24T16:48:34Z

    Hehe, thanks for the patches. (There actually is an edit button, but right now only admins can see it; making it public is on the eventual "to do" list.)

    Will review and get back to you.

  4. Greg Hurrell 2010-03-24T17:22:13Z

    I applied your patch with a couple of tweaks. There was only one (pathological?) case that you didn't explicitly handle, and that's when the window is so small that VIM::Screen.lines - 5 is actually a negative number. Not really a big deal, of course.

  5. Greg Hurrell 2010-03-24T17:22:41Z

    Status changed:

    • From: new
    • To: closed
Add a comment

Comments are now closed for this issue.

  • contact
  • legal

Menu

  • Blog
  • Wiki
  • Issues
  • Snippets