Skip to content

Commit

Permalink
fixed regression issue with search (#2469)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuspen committed Apr 2, 2024
1 parent c10de9f commit ee21871
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ct/ct_actions_find.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ void CtActions::find_replace_in_selected_node()

if (not _s_state.from_find_iterated) {
_s_state.latest_node_offset_match_start = -1;
_s_state.latest_node_offset_match_end = -1;
_s_state.latest_node_offset_node_id = -1;
_s_state.find_iter_anchlist_size = 0u;
text_view_n_buffer_codebox_proof proof = _get_text_view_n_buffer_codebox_proof();
Glib::ustring entry_predefined_text = CtTextIterUtil::get_selected_text(proof.text_view->get_buffer());
Expand Down Expand Up @@ -146,6 +148,8 @@ void CtActions::find_replace_in_multiple_nodes()

if (not _s_state.from_find_iterated) {
_s_state.latest_node_offset_match_start = -1;
_s_state.latest_node_offset_match_end = -1;
_s_state.latest_node_offset_node_id = -1;
_s_state.find_iter_anchlist_size = 0u;
if (_s_state.find_iterated_last_name_n_tags_id > 0) {
_s_state.find_iterated_last_name_n_tags_id = 0;
Expand Down Expand Up @@ -637,11 +641,12 @@ bool CtActions::_find_pattern(CtTreeIter tree_iter,
while (match_info.matches()) {
std::pair<int,int> curr_pair;
match_info.fetch_pos(0, curr_pair.first, curr_pair.second);
if (curr_pair.first > _s_state.latest_node_offset_match_start or
if (curr_pair.first >= _s_state.latest_node_offset_match_end or
node_id != _s_state.latest_node_offset_node_id)
{
match_offsets = curr_pair;
_s_state.latest_node_offset_match_start = match_offsets.first;
_s_state.latest_node_offset_match_end = match_offsets.second;
//spdlog::debug("{}->{}", curr_pair.first, curr_pair.second);
break;
}
Expand All @@ -659,11 +664,12 @@ bool CtActions::_find_pattern(CtTreeIter tree_iter,
match_info.next();
}
for (const auto& curr_pair : match_deque) {
if (curr_pair.first < _s_state.latest_node_offset_match_start or
if (curr_pair.second <= _s_state.latest_node_offset_match_start or
node_id != _s_state.latest_node_offset_node_id)
{
match_offsets = curr_pair;
_s_state.latest_node_offset_match_start = match_offsets.first;
_s_state.latest_node_offset_match_end = match_offsets.second;
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ct/ct_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ struct CtSearchState {
bool all_matches_first_in_node{false};

int latest_node_offset_match_start{-1};
int latest_node_offset_match_end{-1};
gint64 latest_node_offset_node_id{-1};

std::unique_ptr<Gtk::Dialog> iteratedfinddialog;
Expand Down

0 comments on commit ee21871

Please sign in to comment.