Skip to content

Commit

Permalink
Minor stylistic clean-up for jump finder
Browse files Browse the repository at this point in the history
Tweaks to bring the jump finder code into line with the conventions of
the rest of the code base:

  - add a little more detail to the :CommandTJump documentation
  - add Marian Schubert to contributors list
  - alphabetize finder methods in command-t.vim file
  - move getJumpsLines functionality down into Ruby; in general the
    VimScript portion of the plug-in is intended to be a thin wrapper
    only, and all the real work is done from Ruby
  - use "jump" singular rather than plural, because Vim calls it the
    "jumplist" and the other finders all use the singular ("buffer
    finder", "file finder" and not "buffers finder" and "files finder")
  - align equals signs in consecutive assignment statements
  - update copyright year ranges
  - annotate "end" statements for classes and modules
  - make private methods private

Signed-off-by: Wincent Colaiuta <win@wincent.com>
  • Loading branch information
wincent committed Nov 26, 2011
1 parent 55d08de commit 2196598
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
10 changes: 7 additions & 3 deletions doc/command-t.txt
Expand Up @@ -333,10 +333,12 @@ COMMANDS *command-t-commands*
you already have open in buffers.

*:CommandTJumps*
|:CommandTJumps|Brings up the Command-T jumps window.
|:CommandTJump| Brings up the Command-T jumplist window.
This works exactly like the standard file window,
except that the selection is limited to files that
you already have in jumps list.
you already have in the jumplist. Note that jumps
can persist across Vim sessions (see Vim's |jumplist|
documentation for more info).

*:CommandTFlush*
|:CommandTFlush|Instructs the plug-in to flush its path cache, causing
Expand Down Expand Up @@ -584,6 +586,7 @@ order):
Anthony Panozzo
Daniel Hahler
Lucas de Vries
Marian Schubert
Matthew Todd
Mike Lundy
Scott Bronson
Expand Down Expand Up @@ -664,13 +667,14 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.


HISTORY *command-t-history*

1.3 (not yet released)

- added the option to maintain multiple caches when changing among
directories; see the accompanying |g:CommandTMaxCachedDirectories| setting
- added the ability to navigate using the Vim jumplist (patch from Marian
Schubert)

1.2.1 (30 April 2011)

Expand Down
18 changes: 5 additions & 13 deletions plugin/command-t.vim
Expand Up @@ -28,7 +28,7 @@ endif
let g:command_t_loaded = 1

command CommandTBuffer call <SID>CommandTShowBufferFinder()
command CommandTJumps call <SID>CommandTShowJumpsFinder()
command CommandTJump call <SID>CommandTShowJumpFinder()
command -nargs=? -complete=dir CommandT call <SID>CommandTShowFileFinder(<q-args>)
command CommandTFlush call <SID>CommandTFlush()

Expand All @@ -55,17 +55,17 @@ function s:CommandTShowBufferFinder()
endif
endfunction

function s:CommandTShowJumpsFinder()
function s:CommandTShowFileFinder(arg)
if has('ruby')
ruby $command_t.show_jumps_finder
ruby $command_t.show_file_finder
else
call s:CommandTRubyWarning()
endif
endfunction

function s:CommandTShowFileFinder(arg)
function s:CommandTShowJumpFinder()
if has('ruby')
ruby $command_t.show_file_finder
ruby $command_t.show_jump_finder
else
call s:CommandTRubyWarning()
endif
Expand Down Expand Up @@ -147,14 +147,6 @@ function CommandTCursorStart()
ruby $command_t.cursor_start
endfunction

" borrowed from FuzzyFinder
function s:getJumpsLines()
redir => result
:silent jumps
redir END
return split(result, "\n")
endfunction

ruby << EOF
# require Ruby files
begin
Expand Down
12 changes: 6 additions & 6 deletions ruby/command-t/controller.rb
Expand Up @@ -22,7 +22,7 @@
# POSSIBILITY OF SUCH DAMAGE.

require 'command-t/finder/buffer_finder'
require 'command-t/finder/jumps_finder'
require 'command-t/finder/jump_finder'
require 'command-t/finder/file_finder'
require 'command-t/match_window'
require 'command-t/prompt'
Expand All @@ -33,9 +33,9 @@ class Controller
include VIM::PathUtilities

def initialize
@prompt = Prompt.new
@buffer_finder = CommandT::BufferFinder.new
@jumps_finder = CommandT::JumpsFinder.new
@prompt = Prompt.new
@buffer_finder = CommandT::BufferFinder.new
@jump_finder = CommandT::JumpFinder.new
set_up_file_finder
set_up_max_height
end
Expand All @@ -46,9 +46,9 @@ def show_buffer_finder
show
end

def show_jumps_finder
def show_jump_finder
@path = VIM::pwd
@active_finder = @jumps_finder
@active_finder = @jump_finder
show
end

Expand Down
@@ -1,4 +1,4 @@
# Copyright 2010-2011 Wincent Colaiuta. All rights reserved.
# Copyright 2011 Wincent Colaiuta. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand All @@ -22,14 +22,14 @@
# POSSIBILITY OF SUCH DAMAGE.

require 'command-t/ext' # CommandT::Matcher
require 'command-t/scanner/jumps_scanner'
require 'command-t/scanner/jump_scanner'
require 'command-t/finder'

module CommandT
class JumpsFinder < Finder
class JumpFinder < Finder
def initialize
@scanner = JumpsScanner.new
@scanner = JumpScanner.new
@matcher = Matcher.new @scanner, :always_show_dot_files => true
end
end
end
end # class JumpFinder
end # module CommandT
@@ -1,4 +1,4 @@
# Copyright 2010-2011 Wincent Colaiuta. All rights reserved.
# Copyright 2011 Wincent Colaiuta. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -26,8 +26,8 @@
require 'command-t/scanner'

module CommandT
# Returns a list of files in jumps list.
class JumpsScanner < Scanner
# Returns a list of files in the jumplist.
class JumpScanner < Scanner
include VIM::PathUtilities

def paths
Expand All @@ -40,12 +40,17 @@ def paths
filenames.sort.uniq
end

def line_contains_filename?(line)
line.split.count > 3
private

def line_contains_filename? line
line.split.count > 3
end

def jumps
jumps = ::VIM::evaluate("s:getJumpsLines()")
::VIM::command 'silent redir => g:command_t_jumps'
::VIM::command 'silent jumps'
::VIM::command 'silent redir END'
::VIM::evaluate 'g:command_t_jumps'
end
end
end
end # class JumpScanner
end # module CommandT

0 comments on commit 2196598

Please sign in to comment.