mirror of
https://github.com/mawww/kakoune.git
synced 2024-07-15 00:20:29 +03:00
Echo an information message about *scratch* buffer and leave it empty
Having to manually clear the scratch was never really nice and hopefully this will be less annoying and as helpful to newcomers.
This commit is contained in:
parent
727d2391c7
commit
51ec633718
@ -101,9 +101,7 @@ Buffer& BufferManager::get_buffer_matching(const Regex& regex)
|
||||
Buffer& BufferManager::get_first_buffer()
|
||||
{
|
||||
if (all_of(m_buffers, [](auto& b) { return (b->flags() & Buffer::Flags::Debug); }))
|
||||
create_buffer("*scratch*", Buffer::Flags::None,
|
||||
{StringData::create("*** this is a *scratch* buffer which won't be automatically saved ***\n"),
|
||||
StringData::create("*** use it for notes or open a file buffer with the :edit command ***\n")},
|
||||
create_buffer("*scratch*", Buffer::Flags::None, {StringData::create("\n")},
|
||||
ByteOrderMark::None, EolFormat::Lf, {InvalidTime, {}, {}});
|
||||
|
||||
return *m_buffers.back();
|
||||
|
@ -64,24 +64,28 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui, int pi
|
||||
std::move(on_exit)};
|
||||
m_clients.emplace_back(client);
|
||||
|
||||
auto& context = client->context();
|
||||
if (buffer->name() == "*scratch*")
|
||||
context.print_status({"This *scratch* buffer won't be automatically saved",
|
||||
context.faces()["Information"]});
|
||||
|
||||
if (init_coord)
|
||||
{
|
||||
auto& selections = client->context().selections_write_only();
|
||||
auto& selections = context.selections_write_only();
|
||||
selections = SelectionList(*buffer, buffer->clamp(*init_coord));
|
||||
client->context().window().center_line(init_coord->line);
|
||||
context.window().center_line(init_coord->line);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
auto& context = client->context();
|
||||
context.hooks().run_hook(Hook::ClientCreate, context.name(), context);
|
||||
CommandManager::instance().execute(init_cmds, context);
|
||||
}
|
||||
catch (Kakoune::runtime_error& error)
|
||||
{
|
||||
client->context().print_status({error.what().str(), client->context().faces()["Error"]});
|
||||
client->context().hooks().run_hook(Hook::RuntimeError, error.what(),
|
||||
client->context());
|
||||
context.print_status({error.what().str(), context.faces()["Error"]});
|
||||
context.hooks().run_hook(Hook::RuntimeError, error.what(),
|
||||
context);
|
||||
}
|
||||
|
||||
// Do not return the client if it already got moved to the trash
|
||||
|
Loading…
Reference in New Issue
Block a user