diff --git a/text-motions.c b/text-motions.c index 1430d49..2e6f1e8 100644 --- a/text-motions.c +++ b/text-motions.c @@ -533,17 +533,20 @@ size_t text_bracket_match(Text *txt, size_t pos, const Filerange *limits) { static size_t match_symbol(Text *txt, size_t pos, char search, int direction, const Filerange *limits) { char c, current; int count = 1; - bool instring = false; + bool instring = false, escaped; Iterator it = text_iterator_get(txt, pos); if (!text_iterator_byte_get(&it, ¤t)) return pos; + escaped = false; if (direction >= 0) { /* forward search */ while (text_iterator_byte_next(&it, &c)) { if (limits && it.pos >= limits->end) break; - if (c != current && c == '"') + if (c != current && c == '"' && !escaped) instring = !instring; - if (!instring) { + if (instring) { + escaped = c == '\\'; + } else { if (c == search && --count == 0) return it.pos; else if (c == current)