summaryrefslogtreecommitdiff
path: root/src/client_manager.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-01-19 18:44:26 +0000
committerMaxime Coste <mawww@kakoune.org>2017-01-19 18:44:26 +0000
commit6f4515f005d41c03ed18766e68544cb5aca7b8c4 (patch)
tree043211e33d6e442a838a03114e0d1a9387f6efb4 /src/client_manager.cc
parentc61aae0722058ad404ec1c117a277bef437e006e (diff)
Only touch new clients selections when target coord are explicit
Do not implicitely change new clients selections to target coordinates when the user did not specify them, so that we can re-use the selections from the found free window, which is the generally desired behaviour.
Diffstat (limited to 'src/client_manager.cc')
-rw-r--r--src/client_manager.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/client_manager.cc b/src/client_manager.cc
index f2989b90..c7246a82 100644
--- a/src/client_manager.cc
+++ b/src/client_manager.cc
@@ -19,11 +19,11 @@ ClientManager::~ClientManager()
void ClientManager::clear()
{
- m_free_windows.clear();
// So that clients destructor find the client manager empty
// so that local UI does not fork.
ClientList clients = std::move(m_clients);
m_client_trash.clear();
+ m_free_windows.clear();
}
String ClientManager::generate_name() const
@@ -38,7 +38,7 @@ String ClientManager::generate_name() const
Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
EnvVarMap env_vars, StringView init_cmds,
- BufferCoord init_coord)
+ Optional<BufferCoord> init_coord)
{
Buffer& buffer = BufferManager::instance().get_first_buffer();
WindowAndSelections ws = get_free_window(buffer);
@@ -47,9 +47,12 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
generate_name()};
m_clients.emplace_back(client);
- auto& selections = client->context().selections_write_only();
- selections = SelectionList(buffer, buffer.clamp(init_coord));
- client->context().window().center_line(init_coord.line);
+ if (init_coord)
+ {
+ auto& selections = client->context().selections_write_only();
+ selections = SelectionList(buffer, buffer.clamp(*init_coord));
+ client->context().window().center_line(init_coord->line);
+ }
try
{