From 83244af106df14c6062b859b8597c12f72fba4d8 Mon Sep 17 00:00:00 2001 From: Jason Felice Date: Sun, 9 Sep 2018 09:42:02 -0400 Subject: [PATCH] Don't skip opening brace twice when finding closing Fixes #2367 Fixes #2129 --- src/selectors.cc | 2 +- test/regression/2129-inside-parentheses/cmd | 1 + test/regression/2129-inside-parentheses/in | 1 + test/regression/2129-inside-parentheses/selections | 1 + test/regression/2367-surround-with-tight-nesting/cmd | 1 + test/regression/2367-surround-with-tight-nesting/in | 1 + test/regression/2367-surround-with-tight-nesting/selections | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/regression/2129-inside-parentheses/cmd create mode 100644 test/regression/2129-inside-parentheses/in create mode 100644 test/regression/2129-inside-parentheses/selections create mode 100644 test/regression/2367-surround-with-tight-nesting/cmd create mode 100644 test/regression/2367-surround-with-tight-nesting/in create mode 100644 test/regression/2367-surround-with-tight-nesting/selections diff --git a/src/selectors.cc b/src/selectors.cc index 3775cd5e..a11a200d 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -359,7 +359,7 @@ find_surrounding(const Container& container, Iterator pos, first = (flags & ObjectFlags::Inner) ? res->second : res->first; if (flags & ObjectFlags::ToEnd) // ensure we find the matching end { - last = res->second; + last = res->first; level = 0; } } diff --git a/test/regression/2129-inside-parentheses/cmd b/test/regression/2129-inside-parentheses/cmd new file mode 100644 index 00000000..4509b477 --- /dev/null +++ b/test/regression/2129-inside-parentheses/cmd @@ -0,0 +1 @@ +b diff --git a/test/regression/2129-inside-parentheses/in b/test/regression/2129-inside-parentheses/in new file mode 100644 index 00000000..ea6dcaf3 --- /dev/null +++ b/test/regression/2129-inside-parentheses/in @@ -0,0 +1 @@ +((a+b)%(/)(a-b)) diff --git a/test/regression/2129-inside-parentheses/selections b/test/regression/2129-inside-parentheses/selections new file mode 100644 index 00000000..3f9324e8 --- /dev/null +++ b/test/regression/2129-inside-parentheses/selections @@ -0,0 +1 @@ +'(a+b)/(a-b)' diff --git a/test/regression/2367-surround-with-tight-nesting/cmd b/test/regression/2367-surround-with-tight-nesting/cmd new file mode 100644 index 00000000..d567e3bd --- /dev/null +++ b/test/regression/2367-surround-with-tight-nesting/cmd @@ -0,0 +1 @@ +r diff --git a/test/regression/2367-surround-with-tight-nesting/in b/test/regression/2367-surround-with-tight-nesting/in new file mode 100644 index 00000000..d728b88b --- /dev/null +++ b/test/regression/2367-surround-with-tight-nesting/in @@ -0,0 +1 @@ +%([)[a]b] [[c]d%(]) diff --git a/test/regression/2367-surround-with-tight-nesting/selections b/test/regression/2367-surround-with-tight-nesting/selections new file mode 100644 index 00000000..fb210438 --- /dev/null +++ b/test/regression/2367-surround-with-tight-nesting/selections @@ -0,0 +1 @@ +'[[a]b]' '[[c]d]'