diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index 95a27df4..d6dc9ae0 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -25,9 +25,11 @@ BufferManager::~BufferManager() Buffer* BufferManager::create_buffer(String name, Buffer::Flags flags, StringView data, timespec fs_timestamp) { + auto path = real_path(parse_filename(name)); for (auto& buf : m_buffers) { - if (buf->name() == name) + if (buf->name() == name or + (buf->flags() & Buffer::Flags::File and buf->name() == path)) throw name_not_unique(); } diff --git a/src/file.cc b/src/file.cc index 6773e6e0..fdca896f 100644 --- a/src/file.cc +++ b/src/file.cc @@ -90,7 +90,10 @@ String real_path(StringView filename) auto it = find(existing.rbegin(), existing.rend(), '/'); if (it == existing.rend()) - return filename.str(); + { + char cwd[1024]; + return format("{}/{}", getcwd(cwd, 1024), filename); + } existing = StringView{existing.begin(), it.base()-1}; non_existing = StringView{it.base(), filename.end()};