Comments
-
Lucas de Vries
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
-
Lucas de Vries
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
-
Greg Hurrell
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.
-
Greg Hurrell
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. -
Greg Hurrell
Status changed:
- From: new
- To: closed
Add a comment
Comments are now closed for this issue.