From 7335065d20c6573d0327e3da424113849ab827c9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 1 Dec 2015 13:42:42 +0000 Subject: [PATCH] Update buffer display names after changing working directory Fixes #501 --- src/buffer.cc | 6 ++++++ src/buffer.hh | 1 + src/commands.cc | 2 ++ 3 files changed, 9 insertions(+) diff --git a/src/buffer.cc b/src/buffer.cc index 70183b2b..044a8f1e 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -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)); diff --git a/src/buffer.hh b/src/buffer.hh index 72c65e5c..b91a7ed1 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -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); diff --git a/src/commands.cc b/src/commands.cc index 9117dce3..a7d180dc 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -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(); } };