Check all buffer are saved in :kill, and add :kill! to avoid that
This commit is contained in:
parent
61c155fc40
commit
da40828801
|
@ -599,7 +599,8 @@ command `q!` has to be used).
|
|||
* `w[rite]a[ll]`: write all buffers that are associated to a file.
|
||||
* `q[uit][!]`: exit Kakoune, use quit! to force quitting even if there is some
|
||||
unsaved buffers remaining.
|
||||
* `kill`: terminate the current session, all the clients as well as the server
|
||||
* `kill[!]`: terminate the current session, all the clients as well as the server,
|
||||
use kill! to ignore unsaved buffers
|
||||
* `w[a]q[!]`: write the current buffer (or all buffers when `waq` is used) and quit
|
||||
* `b[uffer] <name>`: switch to buffer <name>
|
||||
* `b[uffer]n[ext]`: switch to the next buffer
|
||||
|
|
|
@ -271,21 +271,7 @@ const CommandDesc writeall_cmd = {
|
|||
[](const ParametersParser&, Context&, const ShellContext&){ write_all_buffers(); }
|
||||
};
|
||||
|
||||
const CommandDesc kill_cmd = {
|
||||
"kill",
|
||||
nullptr,
|
||||
"kill current session, quit all clients and server",
|
||||
no_params,
|
||||
CommandFlags::None,
|
||||
CommandHelper{},
|
||||
CommandCompleter{},
|
||||
[](const ParametersParser&, Context&, const ShellContext&){ throw kill_session{}; }
|
||||
};
|
||||
|
||||
template<bool force>
|
||||
void quit()
|
||||
{
|
||||
if (not force and ClientManager::instance().count() == 1)
|
||||
static void ensure_all_buffers_are_saved()
|
||||
{
|
||||
Vector<String> names;
|
||||
for (auto& buffer : BufferManager::instance())
|
||||
|
@ -306,6 +292,38 @@ void quit()
|
|||
throw runtime_error(message);
|
||||
}
|
||||
}
|
||||
|
||||
const CommandDesc kill_cmd = {
|
||||
"kill",
|
||||
nullptr,
|
||||
"kill current session, quit all clients and server",
|
||||
no_params,
|
||||
CommandFlags::None,
|
||||
CommandHelper{},
|
||||
CommandCompleter{},
|
||||
[](const ParametersParser&, Context&, const ShellContext&){
|
||||
ensure_all_buffers_are_saved();
|
||||
throw kill_session{};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const CommandDesc force_kill_cmd = {
|
||||
"kill!",
|
||||
nullptr,
|
||||
"kill current session, quit all clients and server, do not check for unsaved buffers",
|
||||
no_params,
|
||||
CommandFlags::None,
|
||||
CommandHelper{},
|
||||
CommandCompleter{},
|
||||
[](const ParametersParser&, Context&, const ShellContext&){ throw kill_session{}; }
|
||||
};
|
||||
|
||||
template<bool force>
|
||||
void quit()
|
||||
{
|
||||
if (not force and ClientManager::instance().count() == 1)
|
||||
ensure_all_buffers_are_saved();
|
||||
// unwind back to this client event handler.
|
||||
throw client_removed{ true };
|
||||
}
|
||||
|
@ -1872,8 +1890,9 @@ void register_commands()
|
|||
register_command(write_cmd);
|
||||
register_command(writeall_cmd);
|
||||
register_command(writeall_quit_cmd);
|
||||
register_command(quit_cmd);
|
||||
register_command(kill_cmd);
|
||||
register_command(force_kill_cmd);
|
||||
register_command(quit_cmd);
|
||||
register_command(force_quit_cmd);
|
||||
register_command(write_quit_cmd);
|
||||
register_command(force_write_quit_cmd);
|
||||
|
|
Loading…
Reference in New Issue
Block a user