bug: made the regex error one line in search

This commit is contained in:
ClementTsang 2020-05-03 00:08:18 -04:00
parent 39d7450aad
commit 0986b96056
2 changed files with 13 additions and 1 deletions

View File

@ -205,6 +205,8 @@ impl ProcWidgetState {
self.process_search_state.search_state.error_message = None;
} else {
let parsed_query = self.parse_query();
// debug!("PQ: {:?}", parsed_query);
if let Ok(parsed_query) = parsed_query {
self.process_search_state.search_state.query = Some(parsed_query);
self.process_search_state.search_state.is_blank_search = false;

View File

@ -104,6 +104,16 @@ impl From<std::str::Utf8Error> for BottomError {
impl From<regex::Error> for BottomError {
fn from(err: regex::Error) -> Self {
BottomError::QueryError(err.to_string().into())
// We only really want the last part of it... so we'll do it the ugly way:
let err_str = err.to_string();
let error = err_str.split('\n').map(|s| s.trim()).collect::<Vec<_>>();
BottomError::QueryError(
format!(
"Regex error: {}",
error.last().unwrap_or(&"".to_string().as_str())
)
.into(),
)
}
}