lib/textbringer/commands/files.rb in textbringer-1.1.1 vs lib/textbringer/commands/files.rb in textbringer-1.1.2
- old
+ new
@@ -70,10 +70,14 @@
Buffer.current.revert(encoding)
end
define_command(:save_buffer, doc: "Save the current buffer to a file.") do
if Buffer.current.file_name.nil?
- Buffer.current.file_name = read_file_name("File to save in: ")
+ file_name = read_file_name("File to save in: ")
+ if File.directory?(file_name)
+ file_name = File.expand_path(Buffer.current.name, file_name)
+ end
+ Buffer.current.file_name = file_name
next if Buffer.current.file_name.nil?
end
if Buffer.current.file_modified?
unless yes_or_no?("File changed on disk. Save anyway?")
message("Cancelled")