allow edit-method to edit rbx core methods using the full path; also added path_line_for helper to wrap source_location and so support rbx core methods too
This commit is contained in:
parent
e9a1222b59
commit
81d44b0674
|
@ -136,7 +136,12 @@ class Pry
|
||||||
|
|
||||||
# editor is invoked here
|
# editor is invoked here
|
||||||
else
|
else
|
||||||
file, line = meth.source_location
|
if rbx_core?(meth)
|
||||||
|
file, line = rbx_core_path_line_for(meth)
|
||||||
|
else
|
||||||
|
file, line = meth.source_location
|
||||||
|
end
|
||||||
|
|
||||||
set_file_and_dir_locals(file)
|
set_file_and_dir_locals(file)
|
||||||
|
|
||||||
if Pry.editor.respond_to?(:call)
|
if Pry.editor.respond_to?(:call)
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Pry
|
||||||
code = strip_leading_whitespace(meth.source)
|
code = strip_leading_whitespace(meth.source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_file_and_dir_locals(meth.source_location.first)
|
set_file_and_dir_locals(path_line_for(meth).first)
|
||||||
end
|
end
|
||||||
|
|
||||||
[code, code_type]
|
[code, code_type]
|
||||||
|
@ -147,7 +147,7 @@ class Pry
|
||||||
else
|
else
|
||||||
doc = strip_leading_hash_and_whitespace_from_ruby_comments(meth.comment)
|
doc = strip_leading_hash_and_whitespace_from_ruby_comments(meth.comment)
|
||||||
end
|
end
|
||||||
set_file_and_dir_locals(meth.source_location.first)
|
set_file_and_dir_locals(path_line_for(meth).first)
|
||||||
end
|
end
|
||||||
|
|
||||||
[doc, code_type]
|
[doc, code_type]
|
||||||
|
@ -187,11 +187,19 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def path_line_for(meth)
|
||||||
|
if rbx_core?(meth)
|
||||||
|
rbx_core_path_line_for(meth)
|
||||||
|
else
|
||||||
|
meth.source_location
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def make_header(meth, code_type, content)
|
def make_header(meth, code_type, content)
|
||||||
num_lines = "Number of lines: #{Pry::Helpers::Text.bold(content.each_line.count.to_s)}"
|
num_lines = "Number of lines: #{Pry::Helpers::Text.bold(content.each_line.count.to_s)}"
|
||||||
case code_type
|
case code_type
|
||||||
when :ruby
|
when :ruby
|
||||||
file, line = meth.source_location
|
file, line = path_line_for(meth)
|
||||||
"\n#{Pry::Helpers::Text.bold('From:')} #{file} @ line #{line}:\n#{num_lines}\n\n"
|
"\n#{Pry::Helpers::Text.bold('From:')} #{file} @ line #{line}:\n#{num_lines}\n\n"
|
||||||
else
|
else
|
||||||
file = Pry::MethodInfo.info_for(meth).file
|
file = Pry::MethodInfo.info_for(meth).file
|
||||||
|
|
Loading…
Reference in New Issue