From 9230667c114e9912657f9b76e615db7341523db9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 27 Feb 2013 19:08:13 +0100 Subject: [PATCH] Add " and ' support to object selection --- src/main.cc | 2 ++ src/selectors.cc | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index 6e499d30..083b4f40 100644 --- a/src/main.cc +++ b/src/main.cc @@ -360,6 +360,8 @@ void do_select_object(Context& context) { { Key::Modifiers::None, ']' }, std::bind(select_surrounding, _1, CodepointPair{ '[', ']' }, flags) }, { { Key::Modifiers::None, '<' }, std::bind(select_surrounding, _1, CodepointPair{ '<', '>' }, flags) }, { { Key::Modifiers::None, '>' }, std::bind(select_surrounding, _1, CodepointPair{ '<', '>' }, flags) }, + { { Key::Modifiers::None, '"' }, std::bind(select_surrounding, _1, CodepointPair{ '"', '"' }, flags) }, + { { Key::Modifiers::None, '\'' }, std::bind(select_surrounding, _1, CodepointPair{ '\'', '\'' }, flags) }, { { Key::Modifiers::None, 'w' }, std::bind(select_whole_word, _1, flags & SurroundFlags::Inner) }, { { Key::Modifiers::None, 'W' }, std::bind(select_whole_word, _1, flags & SurroundFlags::Inner) }, }; diff --git a/src/selectors.cc b/src/selectors.cc index b9141554..420ea6d8 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -228,13 +228,14 @@ Selection select_surrounding(const Selection& selection, { const bool to_begin = flags & SurroundFlags::ToBegin; const bool to_end = flags & SurroundFlags::ToEnd; + const bool nestable = matching.first != matching.second; Utf8Iterator first = selection.last(); if (to_begin) { int level = 0; while (not is_begin(first)) { - if (first != selection.last() and *first == matching.second) + if (nestable and first != selection.last() and *first == matching.second) ++level; else if (*first == matching.first) { @@ -256,7 +257,7 @@ Selection select_surrounding(const Selection& selection, last = first + 1; while (not is_end(last)) { - if (*last == matching.first) + if (nestable and *last == matching.first) ++level; else if (*last == matching.second) {