mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Edit: handle blanks in filenames correctly
Also, move path escaping to `Editor` class. The test is currently failing (looks like a bug in `Editor`).
This commit is contained in:
parent
5871054c05
commit
e66d2083c1
3 changed files with 12 additions and 6 deletions
|
@ -114,11 +114,8 @@ class Pry
|
|||
|
||||
ensure_file_name_is_valid(file_name)
|
||||
|
||||
# Sanitize blanks.
|
||||
sanitized_file_name = Shellwords.escape(file_name)
|
||||
|
||||
Pry::Editor.invoke_editor(sanitized_file_name, line, reload?(file_name))
|
||||
set_file_and_dir_locals(sanitized_file_name)
|
||||
Pry::Editor.invoke_editor(file_name, line, reload?(file_name))
|
||||
set_file_and_dir_locals(file_name)
|
||||
|
||||
if reload?(file_name)
|
||||
silence_warnings do
|
||||
|
@ -128,7 +125,7 @@ class Pry
|
|||
end
|
||||
|
||||
def filename_argument
|
||||
args.first || ""
|
||||
args.join(' ')
|
||||
end
|
||||
|
||||
def code_object
|
||||
|
|
|
@ -33,6 +33,9 @@ class Pry
|
|||
# all the flags we want as well as the file and line number we
|
||||
# want to open at.
|
||||
def build_editor_invocation_string(file, line, blocking)
|
||||
# Sanitize blanks.
|
||||
file = Shellwords.escape(file)
|
||||
|
||||
if Pry.config.editor.respond_to?(:call)
|
||||
args = [file, line, blocking][0...(Pry.config.editor.arity)]
|
||||
Pry.config.editor.call(*args)
|
||||
|
|
|
@ -39,6 +39,12 @@ describe "edit" do
|
|||
File.exist?(@file).should == true
|
||||
end
|
||||
|
||||
it "works with files that contain blanks in their names" do
|
||||
FileUtils.touch '/tmp/hello world.rb'
|
||||
pry_eval 'edit /tmp/hello world.rb'
|
||||
@file.should == '/tmp/hello world.rb'
|
||||
end
|
||||
|
||||
describe do
|
||||
before do
|
||||
Pad.counter = 0
|
||||
|
|
Loading…
Reference in a new issue