Cache buffer display name
This commit is contained in:
parent
ae7dc3c576
commit
e9d7d70e47
|
@ -20,7 +20,8 @@ namespace Kakoune
|
|||
Buffer::Buffer(String name, Flags flags, BufferLines lines,
|
||||
time_t fs_timestamp)
|
||||
: Scope(GlobalScope::instance()),
|
||||
m_name(flags & Flags::File ? real_path(parse_filename(name)) : std::move(name)),
|
||||
m_name((flags & Flags::File) ? real_path(parse_filename(name)) : std::move(name)),
|
||||
m_display_name((flags & Flags::File) ? compact_path(m_name) : m_name),
|
||||
m_flags(flags | Flags::NoUndo),
|
||||
m_history(), m_history_cursor(m_history.begin()),
|
||||
m_last_save_undo_index(0),
|
||||
|
@ -71,22 +72,21 @@ Buffer::~Buffer()
|
|||
m_values.clear();
|
||||
}
|
||||
|
||||
String Buffer::display_name() const
|
||||
{
|
||||
if (m_flags & Flags::File)
|
||||
return compact_path(m_name);
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool Buffer::set_name(String name)
|
||||
{
|
||||
Buffer* other = BufferManager::instance().get_buffer_ifp(name);
|
||||
if (other == nullptr or other == this)
|
||||
{
|
||||
if (m_flags & Flags::File)
|
||||
{
|
||||
m_name = real_path(name);
|
||||
m_display_name = compact_path(m_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_name = std::move(name);
|
||||
m_display_name = m_name;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
ByteCoordAndTarget offset_coord(ByteCoordAndTarget coord, LineCount offset);
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
String display_name() const;
|
||||
const String& display_name() const { return m_display_name; }
|
||||
|
||||
// returns true if the buffer is in a different state than
|
||||
// the last time it was saved
|
||||
|
@ -199,6 +199,7 @@ private:
|
|||
LineList m_lines;
|
||||
|
||||
String m_name;
|
||||
String m_display_name;
|
||||
Flags m_flags;
|
||||
|
||||
using UndoGroup = Vector<Modification, MemoryDomain::BufferMeta>;
|
||||
|
|
Loading…
Reference in New Issue
Block a user