Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make it possible to select file from jump list

  • Loading branch information...
commit 55d08dea04e62b99e149815ebfa2bc94e5c232e1 1 parent d563170
@maio maio authored wincent committed
View
6 doc/command-t.txt
@@ -332,6 +332,12 @@ COMMANDS *command-t-commands*
except that the selection is limited to files that
you already have open in buffers.
+ *:CommandTJumps*
+|:CommandTJumps|Brings up the Command-T jumps window.
+ This works exactly like the standard file window,
+ except that the selection is limited to files that
+ you already have in jumps list.
+
*:CommandTFlush*
|:CommandTFlush|Instructs the plug-in to flush its path cache, causing
the directory to be rescanned for new or deleted paths
View
17 plugin/command-t.vim
@@ -28,6 +28,7 @@ endif
let g:command_t_loaded = 1
command CommandTBuffer call <SID>CommandTShowBufferFinder()
+command CommandTJumps call <SID>CommandTShowJumpsFinder()
command -nargs=? -complete=dir CommandT call <SID>CommandTShowFileFinder(<q-args>)
command CommandTFlush call <SID>CommandTFlush()
@@ -54,6 +55,14 @@ function s:CommandTShowBufferFinder()
endif
endfunction
+function s:CommandTShowJumpsFinder()
+ if has('ruby')
+ ruby $command_t.show_jumps_finder
+ else
+ call s:CommandTRubyWarning()
+ endif
+endfunction
+
function s:CommandTShowFileFinder(arg)
if has('ruby')
ruby $command_t.show_file_finder
@@ -138,6 +147,14 @@ 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
View
8 ruby/command-t/controller.rb
@@ -22,6 +22,7 @@
# POSSIBILITY OF SUCH DAMAGE.
require 'command-t/finder/buffer_finder'
+require 'command-t/finder/jumps_finder'
require 'command-t/finder/file_finder'
require 'command-t/match_window'
require 'command-t/prompt'
@@ -34,6 +35,7 @@ class Controller
def initialize
@prompt = Prompt.new
@buffer_finder = CommandT::BufferFinder.new
+ @jumps_finder = CommandT::JumpsFinder.new
set_up_file_finder
set_up_max_height
end
@@ -44,6 +46,12 @@ def show_buffer_finder
show
end
+ def show_jumps_finder
+ @path = VIM::pwd
+ @active_finder = @jumps_finder
+ show
+ end
+
def show_file_finder
# optional parameter will be desired starting directory, or ""
@path = File.expand_path(::VIM::evaluate('a:arg'), VIM::pwd)
View
35 ruby/command-t/finder/jumps_finder.rb
@@ -0,0 +1,35 @@
+# Copyright 2010-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:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# 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.
+
+require 'command-t/ext' # CommandT::Matcher
+require 'command-t/scanner/jumps_scanner'
+require 'command-t/finder'
+
+module CommandT
+ class JumpsFinder < Finder
+ def initialize
+ @scanner = JumpsScanner.new
+ @matcher = Matcher.new @scanner, :always_show_dot_files => true
+ end
+ end
+end
View
51 ruby/command-t/scanner/jumps_scanner.rb
@@ -0,0 +1,51 @@
+# Copyright 2010-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:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# 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.
+
+require 'command-t/vim'
+require 'command-t/vim/path_utilities'
+require 'command-t/scanner'
+
+module CommandT
+ # Returns a list of files in jumps list.
+ class JumpsScanner < Scanner
+ include VIM::PathUtilities
+
+ def paths
+ jumps_with_filename = jumps.select do |line|
+ line_contains_filename?(line)
+ end
+ filenames = jumps_with_filename[1..-2].map do |line|
+ relative_path_under_working_directory line.split[3]
+ end
+ filenames.sort.uniq
+ end
+
+ def line_contains_filename?(line)
+ line.split.count > 3
+ end
+
+ def jumps
+ jumps = ::VIM::evaluate("s:getJumpsLines()")
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.