trying to make edit-method more win32 friendly

This commit is contained in:
John Mair 2011-06-09 16:11:36 +12:00
parent 4aacbf7b8f
commit c173e4d600
1 changed files with 11 additions and 7 deletions

View File

@ -143,8 +143,8 @@ class Pry
editor_invocation = Pry.editor.call(file, line)
else
# only use start line if -n option is not used
start_line_syntax = opts["no-jump"] ? "" : start_line_for_editor(line)
editor_invocation = "#{Pry.editor} #{start_line_syntax} #{file}"
start_line_syntax = opts["no-jump"] ? "" : start_line_for_editor(file, line)
editor_invocation = "#{Pry.editor} #{start_line_syntax}"
end
run ".#{editor_invocation}"
@ -156,17 +156,21 @@ class Pry
helpers do
def start_line_for_editor(line_number)
def start_line_for_editor(file_name, line_number)
file_name.gsub!(/\//, '\\') if RUBY_PLATFORM =~ /mswin|mingw/
case Pry.editor
when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/
"+#{line_number}"
"+#{line_number} #{file_name}"
when /^mate/, /^geany/
"-l #{line_number}"
"-l #{line_number} #{file_name}"
when /^uedit32/
"#{file_name}/#{line_number}"
else
if RUBY_PLATFORM =~ /mswin|mingw/
""
"#{file_name}"
else
"+#{line_number}"
"+#{line_number} #{file_name}"
end
end
end