Update buffer display names after changing working directory

Fixes #501
This commit is contained in:
Maxime Coste 2015-12-01 13:42:42 +00:00
parent c71d0e9f8d
commit 7335065d20
3 changed files with 9 additions and 0 deletions

View File

@ -135,6 +135,12 @@ bool Buffer::set_name(String name)
return false;
}
void Buffer::update_display_name()
{
if (m_flags & Flags::File)
m_display_name = compact_path(m_name);
}
BufferIterator Buffer::iterator_at(ByteCoord coord) const
{
return is_end(coord) ? end() : BufferIterator(*this, clamp(coord));

View File

@ -90,6 +90,7 @@ public:
Flags& flags() { return m_flags; }
bool set_name(String name);
void update_display_name();
BufferIterator insert(const BufferIterator& pos, StringView content);
BufferIterator erase(BufferIterator begin, BufferIterator end);

View File

@ -1696,6 +1696,8 @@ const CommandDesc change_working_directory_cmd = {
{
if (chdir(parse_filename(parser[0]).c_str()) != 0)
throw runtime_error(format("cannot change to directory '{}'", parser[0]));
for (auto& buffer : BufferManager::instance())
buffer->update_display_name();
}
};