diff options
| -rw-r--r-- | vis-motions.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/vis-motions.c b/vis-motions.c index 91224b5..63cb0dc 100644 --- a/vis-motions.c +++ b/vis-motions.c @@ -16,9 +16,14 @@ static bool search_word(Vis *vis, Text *txt, size_t pos) { char *buf = text_bytes_alloc0(txt, word.start, text_range_size(&word)); if (!buf) return false; - snprintf(expr, sizeof(expr), "\\<%s\\>", buf); + snprintf(expr, sizeof(expr), "[[:<:]]%s[[:>:]]", buf); + bool ret = text_regex_compile(vis->search_pattern, expr, REG_EXTENDED) == 0; + if (!ret) { + snprintf(expr, sizeof(expr), "\\<%s\\>", buf); + ret = text_regex_compile(vis->search_pattern, expr, REG_EXTENDED) == 0; + } free(buf); - return text_regex_compile(vis->search_pattern, expr, REG_EXTENDED) == 0; + return ret; } /** motion implementations */ |
