Skip to content

Commit

Permalink
Moved some functions around
Browse files Browse the repository at this point in the history
  • Loading branch information
silky authored and wincent committed Feb 21, 2012
1 parent eb0cf45 commit ad45f0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
19 changes: 6 additions & 13 deletions ruby/command-t/controller.rb
Expand Up @@ -207,13 +207,6 @@ def get_list_or_string name
end
end

# Backslash-escape space, \, |, %, #, "
def sanitize_path_string str
# for details on escaping command-line mode arguments see: :h :
# (that is, help on ":") in the Vim documentation.
str.gsub(/[ \\|%#"]/, '\\\\\0')
end

def default_open_command
if !get_bool('&hidden') && get_bool('&modified')
'sp'
Expand Down Expand Up @@ -244,14 +237,14 @@ def ensure_appropriate_window_selection

def open_selection selection, options = {}
command = options[:command] || default_open_command
selection = File.expand_path selection, @path
selection = relative_path_under_working_directory selection
selection = sanitize_path_string selection
ensure_appropriate_window_selection

# The following has been moved to 'finder.rb'
# selection = File.expand_path selection, @path
# selection = relative_path_under_working_directory selection
# selection = sanitize_path_string selection

ensure_appropriate_window_selection
@active_finder.open_selection command, selection, options
# was:
# ::VIM::command "silent #{command} #{selection}"
end

def map key, function, param = nil
Expand Down
17 changes: 17 additions & 0 deletions ruby/command-t/finder.rb
Expand Up @@ -22,6 +22,7 @@
# POSSIBILITY OF SUCH DAMAGE.

require 'command-t/ext' # CommandT::Matcher
require 'command-t/vim/path_utilities'

module CommandT
# Encapsulates a Scanner instance (which builds up a list of available files
Expand All @@ -48,11 +49,27 @@ def flush
end

def open_selection command, selection, options = {}
# Default implementation, children can re-implement this at their leisure.

selection = File.expand_path selection, @path
selection = relative_path_under_working_directory selection
selection = sanitize_path_string selection

::VIM::command "silent #{command} #{selection}"
end

def path= path
@scanner.path = path
end


private

# Backslash-escape space, \, |, %, #, "
def sanitize_path_string str
# for details on escaping command-line mode arguments see: :h :
# (that is, help on ":") in the Vim documentation.
str.gsub(/[ \\|%#"]/, '\\\\\0')
end
end # class Finder
end # CommandT

0 comments on commit ad45f0e

Please sign in to comment.