From c173e4d600caddc5758a1864cdc3fc8c0e62fbb7 Mon Sep 17 00:00:00 2001 From: John Mair Date: Thu, 9 Jun 2011 16:11:36 +1200 Subject: [PATCH] trying to make edit-method more win32 friendly --- lib/pry/default_commands/introspection.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/pry/default_commands/introspection.rb b/lib/pry/default_commands/introspection.rb index 00a14243..d8175078 100644 --- a/lib/pry/default_commands/introspection.rb +++ b/lib/pry/default_commands/introspection.rb @@ -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