From d2509e54f2d4953e12ecb0d1acca3a6761b1abf5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 30 Jul 2018 07:15:17 +0100 Subject: [PATCH] Fix compilation with gcc-5 Gcc-5 seems to have a bug in its handling of template variable. Fixes #2267 --- .travis.yml | 6 +++--- src/commands.cc | 49 ++++++++++++++++++++++++------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb8f529d..03e3e1ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_install: install: - if [ $TRAVIS_OS_NAME = linux ]; then if [ "$CXX" = "g++" ]; then - export CXX=g++-6; + export CXX=g++-5; fi; elif [ $TRAVIS_OS_NAME = osx ]; then brew outdated gcc || brew upgrade gcc; @@ -35,8 +35,8 @@ addons: sources: - ubuntu-toolchain-r-test packages: - - libstdc++-6-dev - - g++-6 + - libstdc++-5-dev + - g++-5 - libncursesw5-dev coverity_scan: project: diff --git a/src/commands.cc b/src/commands.cc index 02e797c5..dcee0281 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1498,33 +1498,32 @@ const CommandDesc declare_option_cmd = { }; template -static auto map_key_completer = - [](const Context& context, CompletionFlags flags, - CommandParameters params, size_t token_to_complete, - ByteCount pos_in_token) -> Completions +static Completions map_key_completer(const Context& context, CompletionFlags flags, + CommandParameters params, size_t token_to_complete, + ByteCount pos_in_token) +{ + if (token_to_complete == 0) + return { 0_byte, params[0].length(), + complete(params[0], pos_in_token, scopes) }; + if (token_to_complete == 1) { - if (token_to_complete == 0) - return { 0_byte, params[0].length(), - complete(params[0], pos_in_token, scopes) }; - if (token_to_complete == 1) - { - auto& user_modes = get_scope(params[0], context).keymaps().user_modes(); - return { 0_byte, params[1].length(), - complete(params[1], pos_in_token, concatenated(modes, user_modes) | gather>()) }; - } - if (unmap and token_to_complete == 2) - { - KeymapManager& keymaps = get_scope(params[0], context).keymaps(); - KeymapMode keymap_mode = parse_keymap_mode(params[1], keymaps.user_modes()); - KeyList keys = keymaps.get_mapped_keys(keymap_mode); + auto& user_modes = get_scope(params[0], context).keymaps().user_modes(); + return { 0_byte, params[1].length(), + complete(params[1], pos_in_token, concatenated(modes, user_modes) | gather>()) }; + } + if (unmap and token_to_complete == 2) + { + KeymapManager& keymaps = get_scope(params[0], context).keymaps(); + KeymapMode keymap_mode = parse_keymap_mode(params[1], keymaps.user_modes()); + KeyList keys = keymaps.get_mapped_keys(keymap_mode); - return { 0_byte, params[2].length(), - complete(params[2], pos_in_token, - keys | transform([](Key k) { return key_to_str(k); }) - | gather>()) }; - } - return {}; - }; + return { 0_byte, params[2].length(), + complete(params[2], pos_in_token, + keys | transform([](Key k) { return key_to_str(k); }) + | gather>()) }; + } + return {}; +} const CommandDesc map_key_cmd = { "map",