diff --git a/src/client.cc b/src/client.cc index 95802181..574a481e 100644 --- a/src/client.cc +++ b/src/client.cc @@ -64,7 +64,9 @@ DisplayLine Client::generate_mode_line() const void Client::change_buffer(Buffer& buffer) { ClientManager::instance().add_free_window(std::move(m_window), std::move(context().selections())); - std::tie(m_window, context().m_selections) = ClientManager::instance().get_free_window(buffer); + WindowAndSelections ws = ClientManager::instance().get_free_window(buffer); + m_window = std::move(ws.window); + context().m_selections = std::move(ws.selections); context().set_window(*m_window); m_window->set_dimensions(ui().dimensions()); m_window->hooks().run_hook("WinDisplay", buffer.name(), context()); diff --git a/src/client_manager.cc b/src/client_manager.cc index e5a3018b..5c5ad902 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -29,8 +29,8 @@ Client* ClientManager::create_client(std::unique_ptr&& ui, { Buffer& buffer = **BufferManager::instance().begin(); WindowAndSelections ws = get_free_window(buffer); - Client* client = new Client{std::move(ui), std::move(std::get<0>(ws)), - std::move(std::get<1>(ws)), generate_name()}; + Client* client = new Client{std::move(ui), std::move(ws.window), + std::move(ws.selections), generate_name()}; m_clients.emplace_back(client); try { @@ -86,7 +86,7 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer) for (auto it = m_free_windows.begin(), end = m_free_windows.end(); it != end; ++it) { - auto& w = std::get<0>(*it); + auto& w = it->window; if (&w->buffer() == &buffer) { w->forget_timestamp(); @@ -101,7 +101,7 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer) void ClientManager::add_free_window(std::unique_ptr&& window, SelectionList selections) { Buffer& buffer = window->buffer(); - m_free_windows.emplace_back(std::move(window), DynamicSelectionList{ buffer, std::move(selections) }); + m_free_windows.push_back({ std::move(window), DynamicSelectionList{ buffer, std::move(selections) } }); } void ClientManager::ensure_no_client_uses_buffer(Buffer& buffer) @@ -131,7 +131,7 @@ void ClientManager::ensure_no_client_uses_buffer(Buffer& buffer) } auto end = std::remove_if(m_free_windows.begin(), m_free_windows.end(), [&buffer](const WindowAndSelections& ws) - { return &std::get<0>(ws)->buffer() == &buffer; }); + { return &ws.window->buffer() == &buffer; }); m_free_windows.erase(end, m_free_windows.end()); } diff --git a/src/client_manager.hh b/src/client_manager.hh index 9c32404a..b20a1a69 100644 --- a/src/client_manager.hh +++ b/src/client_manager.hh @@ -8,8 +8,11 @@ namespace Kakoune struct client_removed{}; -using WindowAndSelections = std::tuple, - DynamicSelectionList>; +struct WindowAndSelections +{ + std::unique_ptr window; + DynamicSelectionList selections; +}; class ClientManager : public Singleton { diff --git a/src/command_manager.hh b/src/command_manager.hh index 78c93dd1..83c865cc 100644 --- a/src/command_manager.hh +++ b/src/command_manager.hh @@ -14,7 +14,7 @@ namespace Kakoune { -struct Context; +class Context; using CommandParameters = memoryview; using Command = std::function; using CommandCompleter = std::function BufferCoord { if (buffer[c.line].length() == c.column) - return BufferCoord{c.line+1, 0}; + return {c.line+1, 0}; return c; }; for (; begin != end; ++begin) diff --git a/src/main.cc b/src/main.cc index fb2b2307..63644b93 100644 --- a/src/main.cc +++ b/src/main.cc @@ -95,15 +95,15 @@ void register_env_vars() { return context.options()[name.substr(4_byte)].get_as_string(); } }, { "reg_.+", - [](const String& name, const Context& context) + [](const String& name, const Context& context) -> String { return RegisterManager::instance()[name[4]].values(context)[0]; } }, { "session", - [](const String& name, const Context& context) + [](const String& name, const Context& context) -> String { return Server::instance().session(); } }, { "client", - [](const String& name, const Context& context) + [](const String& name, const Context& context) -> String { return context.name(); } }, { "cursor_line", diff --git a/src/normal.cc b/src/normal.cc index 7f1944df..9ed8127c 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1308,8 +1308,8 @@ KeyMap keymap = { alt('a'), select_object }, { ']', select_object }, { '[', select_object }, - { '}', select_object }, { '{', select_object }, + { '}', select_object }, { alt('j'), join }, { alt('J'), join_select_spaces }, @@ -1317,8 +1317,8 @@ KeyMap keymap = { alt('k'), keep }, { alt('K'), keep }, - { '<', deindent }, - { '>', indent }, + { '<', deindent }, + { '>', indent }, { alt('>'), indent }, { alt('<'), deindent }, diff --git a/src/selectors.hh b/src/selectors.hh index 0ffdc745..5f0cf5bc 100644 --- a/src/selectors.hh +++ b/src/selectors.hh @@ -213,7 +213,7 @@ enum Direction { Forward, Backward }; using MatchResults = boost::match_results; -static bool find_last_match(BufferIterator begin, const BufferIterator& end, +inline bool find_last_match(BufferIterator begin, const BufferIterator& end, MatchResults& res, const Regex& regex) { MatchResults matches; diff --git a/src/shell_manager.hh b/src/shell_manager.hh index cee125bf..0774fdf2 100644 --- a/src/shell_manager.hh +++ b/src/shell_manager.hh @@ -9,7 +9,7 @@ namespace Kakoune { -struct Context; +class Context; using EnvVarRetriever = std::function; using EnvVarMap = std::unordered_map;