select_matching: fix when matching is the first character

This commit is contained in:
Maxime Coste 2012-12-27 13:41:45 +01:00
parent f3a7c76c4e
commit ac778c8aa2

View File

@ -205,12 +205,14 @@ Selection select_matching(const Selection& selection)
int level = 0; int level = 0;
const Codepoint opening = *(match-1); const Codepoint opening = *(match-1);
const Codepoint closing = *match; const Codepoint closing = *match;
while (not is_begin(it)) while (true)
{ {
if (*it == closing) if (*it == closing)
++level; ++level;
else if (*it == opening and --level == 0) else if (*it == opening and --level == 0)
return utf8_selection(begin, it); return utf8_selection(begin, it);
if (is_begin(it))
break;
--it; --it;
} }
} }