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, '>' }, 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<false>, _1, flags & SurroundFlags::Inner) },
|
||||||
{ { Key::Modifiers::None, 'W' }, std::bind(select_whole_word<true>, _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_begin = flags & SurroundFlags::ToBegin;
|
||||||
const bool to_end = flags & SurroundFlags::ToEnd;
|
const bool to_end = flags & SurroundFlags::ToEnd;
|
||||||
|
const bool nestable = matching.first != matching.second;
|
||||||
Utf8Iterator first = selection.last();
|
Utf8Iterator first = selection.last();
|
||||||
if (to_begin)
|
if (to_begin)
|
||||||
{
|
{
|
||||||
int level = 0;
|
int level = 0;
|
||||||
while (not is_begin(first))
|
while (not is_begin(first))
|
||||||
{
|
{
|
||||||
if (first != selection.last() and *first == matching.second)
|
if (nestable and first != selection.last() and *first == matching.second)
|
||||||
++level;
|
++level;
|
||||||
else if (*first == matching.first)
|
else if (*first == matching.first)
|
||||||
{
|
{
|
||||||
|
@ -256,7 +257,7 @@ Selection select_surrounding(const Selection& selection,
|
||||||
last = first + 1;
|
last = first + 1;
|
||||||
while (not is_end(last))
|
while (not is_end(last))
|
||||||
{
|
{
|
||||||
if (*last == matching.first)
|
if (nestable and *last == matching.first)
|
||||||
++level;
|
++level;
|
||||||
else if (*last == matching.second)
|
else if (*last == matching.second)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user