diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-01-27 08:28:25 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-01-27 19:36:31 +0000 |
| commit | b7530b021a1b04eadce26cc2480e8f8decfdcc46 (patch) | |
| tree | dd56dbbe12c347ad843a7581310d3b4f59d3960e /src/normal.cc | |
| parent | f8106690b1ea1f307671bb347cc86869c1c88d2c (diff) | |
StringView based surround selection
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/normal.cc b/src/normal.cc index 7154f409..1c2ec6d3 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -941,23 +941,26 @@ void select_object(Context& context, NormalParams params) static constexpr struct { - MatchingPair pair; + StringView opening; + StringView closing; Codepoint name; } surrounding_pairs[] = { - { { '(', ')' }, 'b' }, - { { '{', '}' }, 'B' }, - { { '[', ']' }, 'r' }, - { { '<', '>' }, 'a' }, - { { '"', '"' }, 'Q' }, - { { '\'', '\'' }, 'q' }, - { { '`', '`' }, 'g' }, + { "(", ")", 'b' }, + { "{", "}", 'B' }, + { "[", "]", 'r' }, + { "<", ">", 'a' }, + { "\"", "\"", 'Q' }, + { "'", "'", 'q' }, + { "`", "`", 'g' }, }; for (auto& sur : surrounding_pairs) { - if (sur.pair.opening == *cp or sur.pair.closing == *cp or + if (sur.opening[0_char] == *cp or + sur.closing[0_char] == *cp or (sur.name != 0 and sur.name == *cp)) return select<mode>(context, std::bind(select_surrounding, _1, _2, - sur.pair, level, flags)); + sur.opening, sur.closing, + level, flags)); } }, "select object", "b,(,): parenthesis block\n" |
