Write file to argument given to 'w' command, if present
This commit is contained in:
parent
909e56d5af
commit
8d158e4ed9
@ -83,6 +83,10 @@ public:
|
||||
{
|
||||
return !(*this == s);
|
||||
}
|
||||
std::string to_string() const
|
||||
{
|
||||
return std::string((const char *)&(*m_data)[0], m_size);
|
||||
}
|
||||
|
||||
protected:
|
||||
Encoding::Type m_encoding;
|
||||
|
@ -552,9 +552,22 @@ void Window::handle_command(const EncodedString & command)
|
||||
void Window::command_write_file(const CommandParser & cp)
|
||||
{
|
||||
std::shared_ptr<Buffer> buffer = m_focused_buffer_pane->buffer();
|
||||
if (buffer->filename())
|
||||
std::string path;
|
||||
if (cp.size() >= 2)
|
||||
{
|
||||
buffer->write_to_file(buffer->filename()->c_str());
|
||||
path = cp[1].to_string();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto filename = buffer->filename();
|
||||
if (filename)
|
||||
{
|
||||
path = *filename;
|
||||
}
|
||||
}
|
||||
if (path != "")
|
||||
{
|
||||
buffer->write_to_file(path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user