display modified buffers names when quit fails

This commit is contained in:
Maxime Coste 2012-03-25 20:12:35 +00:00
parent 792f0f7f2e
commit 3dd96565b3

View File

@ -249,13 +249,24 @@ void quit(const CommandParameters& params, const Context& context)
if (not force) if (not force)
{ {
std::vector<std::string> names;
for (auto& buffer : BufferManager::instance()) for (auto& buffer : BufferManager::instance())
{ {
if (buffer.type() != Buffer::Type::Scratch and buffer.is_modified()) if (buffer.type() != Buffer::Type::Scratch and buffer.is_modified())
names.push_back(buffer.name());
}
if (not names.empty())
{
std::string message = "modified buffers remaining: [";
for (auto it = names.begin(); it != names.end(); ++it)
{ {
NCurses::print_status("modified buffer remaining"); if (it != names.begin())
return; message += ", ";
message += *it;
} }
message += "]";
NCurses::print_status(message);
return;
} }
} }
quit_requested = true; quit_requested = true;