Skip to content

Commit

Permalink
fixed regression searching in multiple nodes, only nodes names and ta…
Browse files Browse the repository at this point in the history
…gs, not working (#2461, #2408)
  • Loading branch information
giuspen committed Mar 22, 2024
1 parent 07f1f35 commit 5d805d8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/ct/ct_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ class CtActions
private:
// helpers for find actions
void _find_init();
bool _parse_given_node_content(CtTreeIter node_iter,
Glib::RefPtr<Glib::Regex> re_pattern,
bool forward,
bool first_fromsel,
bool all_matches);
CtMatchType _parse_given_node_content(CtTreeIter node_iter,
Glib::RefPtr<Glib::Regex> re_pattern,
bool forward,
bool first_fromsel,
bool all_matches);
bool _parse_node_content_iter(const CtTreeIter& tree_iter,
Glib::RefPtr<Gtk::TextBuffer> text_buffer,
Glib::RefPtr<Glib::Regex> re_pattern,
Expand Down
37 changes: 23 additions & 14 deletions src/ct/ct_actions_find.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,14 @@ void CtActions::find_in_multiple_nodes_ok_clicked()
break;
}
}
while (_parse_given_node_content(ct_node_iter, re_pattern, forward, first_fromsel, all_matches)) {
CtMatchType matchType;
auto f_matchTypeNotNone = [&](){
matchType = _parse_given_node_content(ct_node_iter, re_pattern, forward, first_fromsel, all_matches);
return CtMatchType::None != matchType;
};
while (f_matchTypeNotNone()) {
++_s_state.matches_num;
if (not all_matches or ctStatusBar.is_progress_stop()) break;
if (not all_matches or ctStatusBar.is_progress_stop() or CtMatchType::NameNTags == matchType) break;
}
++_s_state.processed_nodes;
if (_s_state.matches_num > 0 and not all_matches) break;
Expand Down Expand Up @@ -354,11 +359,11 @@ void CtActions::find_allmatchesdialog_restore()
}

// Returns True if pattern was found, False otherwise
bool CtActions::_parse_given_node_content(CtTreeIter node_iter,
Glib::RefPtr<Glib::Regex> re_pattern,
bool forward,
bool first_fromsel,
bool all_matches)
CtMatchType CtActions::_parse_given_node_content(CtTreeIter node_iter,
Glib::RefPtr<Glib::Regex> re_pattern,
bool forward,
bool first_fromsel,
bool all_matches)
{
const gint64 argNodeId = node_iter.get_node_id();
std::optional<bool> optFirstNode;
Expand All @@ -384,18 +389,17 @@ bool CtActions::_parse_given_node_content(CtTreeIter node_iter,
all_matches,
optFirstNode.value()))
{
return true;
return CtMatchType::Content;
}
}
if (_s_options.node_name_n_tags) {
if (_parse_node_name_n_tags_iter(node_iter, re_pattern, all_matches) and not all_matches) {

if (_parse_node_name_n_tags_iter(node_iter, re_pattern, all_matches)) {
if (_s_state.find_iterated_last_name_n_tags_id <= 0 or
_s_state.find_iterated_last_name_n_tags_id != argNodeId)
{
_s_state.find_iterated_last_name_n_tags_id = argNodeId;
spdlog::debug("{} find_iterated_last_name_n_tags_id {}", __FUNCTION__, _s_state.find_iterated_last_name_n_tags_id);
return true;
return CtMatchType::NameNTags;
}
spdlog::debug("skipped name_n_tags {}", argNodeId);
}
Expand All @@ -421,9 +425,14 @@ bool CtActions::_parse_given_node_content(CtTreeIter node_iter,
break;
}
}
while (_parse_given_node_content(ct_node_iter, re_pattern, forward, first_fromsel, all_matches)) {
CtMatchType matchType;
auto f_matchTypeNotNone = [&](){
matchType = _parse_given_node_content(ct_node_iter, re_pattern, forward, first_fromsel, all_matches);
return CtMatchType::None != matchType;
};
while (f_matchTypeNotNone()) {
++_s_state.matches_num;
if (not all_matches or _pCtMainWin->get_status_bar().is_progress_stop()) break;
if (not all_matches or _pCtMainWin->get_status_bar().is_progress_stop() or CtMatchType::NameNTags == matchType) break;
}
if (_s_state.matches_num > 0 and not all_matches) break;
if (forward) child_iter = ++child_iter;
Expand All @@ -435,7 +444,7 @@ bool CtActions::_parse_given_node_content(CtTreeIter node_iter,
}
}
}
return false;
return CtMatchType::None;
}

// Returns True if pattern was found, False otherwise
Expand Down
2 changes: 2 additions & 0 deletions src/ct/ct_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ enum class CtDuplicateShared { None, Duplicate, Shared };

enum class CtRestoreExpColl : int { FROM_STR=0, ALL_EXP=1, ALL_COLL=2 };

enum class CtMatchType { None, Content, NameNTags };

class CtCodebox;
class CtMainWin;
using CtPairCodeboxMainWin = std::pair<CtCodebox*, CtMainWin*>;
Expand Down

0 comments on commit 5d805d8

Please sign in to comment.