Skip to content

Commit b18e88c

Browse files
committed
Sort results at the end of select_matches
Because selections may overlap, it is possible for result not to be correctly sorted, as for example, we could be selecting '[ab]' in 'a b' selected twice, which would result in (a, b, a, b) when the correctly sorted selection list should be (a, a, b, b).
1 parent 41bb1e2 commit b18e88c

File tree

5 files changed

+7
-1
lines changed

5 files changed

+7
-1
lines changed

src/selectors.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,6 @@ Vector<Selection> select_matches(const Buffer& buffer, ConstArrayView<Selection>
956956
submatch.second.coord()));
957957

958958
auto begin = capture.first, end = capture.second;
959-
kak_assert(result.empty() or begin.coord() >= result.back().min());
960959
result.push_back(
961960
keep_direction({ begin.coord(),
962961
(begin == end ? end : utf8::previous(end, begin)).coord(),
@@ -965,6 +964,8 @@ Vector<Selection> select_matches(const Buffer& buffer, ConstArrayView<Selection>
965964
}
966965
if (result.empty())
967966
throw runtime_error("nothing selected");
967+
968+
std::sort(result.begin(), result.end(), compare_selections);
968969
return result;
969970
}
970971

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
%5<lt><a-s><a-h><semicolon>?\S<ret>s<space>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(
2+
cd foobar
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set-option global indentwidth 2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ui_out -ignore 10

0 commit comments

Comments
 (0)