Add " and ' support to object selection
This commit is contained in:
parent
be0c5ddf49
commit
9230667c11
|
@ -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<false>, _1, flags & SurroundFlags::Inner) },
|
||||
{ { Key::Modifiers::None, 'W' }, std::bind(select_whole_word<true>, _1, flags & SurroundFlags::Inner) },
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user