diff --git a/src/highlighters.cc b/src/highlighters.cc index 905c5632..eec224a5 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -405,7 +405,7 @@ public: DynamicRegexHighlighter(RegexGetter regex_getter, FaceGetter face_getter) : m_regex_getter(std::move(regex_getter)), m_face_getter(std::move(face_getter)), - m_highlighter(Regex(), FacesSpec{}) {} + m_highlighter(Regex{}, FacesSpec{}) {} void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range) { diff --git a/src/input_handler.cc b/src/input_handler.cc index 4e74f3b9..8eee6eb5 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -483,7 +483,7 @@ public: if (m_edit_filter) { m_edit_filter = false; - m_filter = Regex(".*"); + m_filter = Regex{".*"}; m_filter_editor.reset(""); context().print_status(DisplayLine{}); } @@ -522,7 +522,7 @@ public: m_filter_editor.handle_key(key); auto search = ".*" + m_filter_editor.line() + ".*"; - m_filter = Regex(search.begin(), search.end()); + m_filter = Regex{search}; auto it = std::find_if(m_selected, m_choices.end(), match_filter); if (it == m_choices.end()) it = std::find_if(m_choices.begin(), m_selected, match_filter); @@ -562,7 +562,7 @@ private: m_callback(selected, MenuEvent::Select, context()); } - Regex m_filter = Regex(".*"); + Regex m_filter = Regex{".*"}; bool m_edit_filter = false; LineEditor m_filter_editor; }; diff --git a/src/normal.cc b/src/normal.cc index 38cfab0e..dea10516 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -592,9 +592,8 @@ void regex_prompt(Context& context, const String prompt, T func) if (event == PromptEvent::Validate) context.push_jump(); - Regex regex = str.empty() ? Regex{} - : Regex{str.begin(), str.end()}; - func(std::move(regex), event, context); + + func(str.empty() ? Regex{} : Regex{str}, event, context); } catch (regex_error& err) { @@ -620,7 +619,7 @@ void search(Context& context, NormalParams) regex_prompt(context, direction == Forward ? "search:" : "reverse search:", [](Regex ex, PromptEvent event, Context& context) { if (ex.empty()) - ex = Regex{context.main_sel_register_value("/").str()}; + ex = Regex{context.main_sel_register_value("/")}; else if (event == PromptEvent::Validate) RegisterManager::instance()['/'] = ex.str(); if (not ex.empty() and not ex.str().empty()) @@ -634,7 +633,7 @@ void search_next(Context& context, NormalParams params) StringView str = context.main_sel_register_value("/"); if (not str.empty()) { - Regex ex{str.begin(), str.end()}; + Regex ex{str}; do { select_next_match(context.buffer(), context.selections(), ex); } while (--params.count > 0); @@ -679,7 +678,7 @@ void select_regex(Context& context, NormalParams) { regex_prompt(context, "select:", [](Regex ex, PromptEvent event, Context& context) { if (ex.empty()) - ex = Regex{context.main_sel_register_value("/").str()}; + ex = Regex{context.main_sel_register_value("/")}; else if (event == PromptEvent::Validate) RegisterManager::instance()['/'] = ex.str(); if (not ex.empty() and not ex.str().empty()) @@ -691,7 +690,7 @@ void split_regex(Context& context, NormalParams) { regex_prompt(context, "split:", [](Regex ex, PromptEvent event, Context& context) { if (ex.empty()) - ex = Regex{context.main_sel_register_value("/").str()}; + ex = Regex{context.main_sel_register_value("/")}; else if (event == PromptEvent::Validate) RegisterManager::instance()['/'] = ex.str(); if (not ex.empty() and not ex.str().empty()) diff --git a/src/regex.cc b/src/regex.cc index c650651c..39a298cc 100644 --- a/src/regex.cc +++ b/src/regex.cc @@ -13,7 +13,7 @@ String option_to_string(const Regex& re) void option_from_string(StringView str, Regex& re) { - re = Regex{str.begin(), str.end()}; + re = Regex{str}; } } diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 37221204..8aacee35 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -138,7 +138,7 @@ std::pair ShellManager::eval( void ShellManager::register_env_var(StringView regex, EnvVarRetriever retriever) { - m_env_vars.push_back({ Regex(regex.begin(), regex.end()), std::move(retriever) }); + m_env_vars.push_back({ Regex{regex}, std::move(retriever) }); } String ShellManager::get_val(StringView name, const Context& context) const