diff --git a/Frameworks/editor/src/editor.cc b/Frameworks/editor/src/editor.cc index a55eb3d9..3ef55835 100644 --- a/Frameworks/editor/src/editor.cc +++ b/Frameworks/editor/src/editor.cc @@ -1471,6 +1471,8 @@ namespace ng void editor_t::find (std::string const& searchFor, find::options_t options, bool searchOnlySelection) { + set_match_captures(std::map()); + ranges_t res; if(options & find::all_matches) { @@ -1486,8 +1488,12 @@ namespace ng } else { - citerate(pair, ng::find(_buffer, _selections, searchFor, options)) - res.push_back(pair->first); + auto matches = ng::find(_buffer, _selections, searchFor, options); + for(auto const& pair : matches) + res.push_back(pair.first); + + if(matches.size() == 1) + set_match_captures(matches.begin()->second); } if(!res.empty()) diff --git a/Frameworks/editor/src/editor.h b/Frameworks/editor/src/editor.h index ecfba551..2b435aa4 100644 --- a/Frameworks/editor/src/editor.h +++ b/Frameworks/editor/src/editor.h @@ -183,6 +183,7 @@ namespace ng scope::context_t scope (std::string const& scopeAttributes) const; std::map editor_variables (std::string const& scopeAttributes) const; + std::map const& match_captures () const { return _match_captures; } std::vector const& choices () const; std::string placeholder_content (ng::range_t* placeholderSelection = NULL) const; @@ -271,6 +272,7 @@ namespace ng ranges_t snippet (size_t from, size_t to, std::string const& str, std::map const& variables, bool disableIndent); void find (std::string const& searchFor, find::options_t options = find::none, bool searchOnlySelection = false); + void set_match_captures (std::map const& match_captures) { _match_captures = match_captures; } ranges_t replace (std::multimap const& replacements, bool selectInsertions = false); void move_selection (int deltaX, int deltaY); @@ -283,6 +285,7 @@ namespace ng snippet_controller_t _snippets; completion_info_t _completion_info; + std::map _match_captures; clipboard_ptr _clipboard; clipboard_ptr _find_clipboard;