mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-03 10:20:36 +08:00
bin: Fix search cursor on apply / cancel
This commit is contained in:
@@ -172,12 +172,10 @@ impl Browser {
|
||||
}),
|
||||
search: TextField::default()
|
||||
.to_widget(tx.clone())
|
||||
.on_event(|key, s, _| match key {
|
||||
Key::Esc => Some(Message::CloseSearch),
|
||||
Key::Char('\n') => Some(Message::ApplySearch),
|
||||
_ => Some(Message::UpdateSearch {
|
||||
.on_event(|_, s, _| {
|
||||
Some(Message::UpdateSearch {
|
||||
value: s.and_then(|i| i.unwrap_string()).unwrap_or_default(),
|
||||
}),
|
||||
})
|
||||
})
|
||||
.on_update(|state: &State| {
|
||||
TextFieldProps::default()
|
||||
@@ -202,8 +200,17 @@ impl View for Browser {
|
||||
.unwrap_or(&default);
|
||||
|
||||
if props.show_search {
|
||||
self.search.handle_event(key);
|
||||
None
|
||||
match key {
|
||||
Key::Esc => {
|
||||
self.search.reset();
|
||||
Some(Message::CloseSearch)
|
||||
}
|
||||
Key::Char('\n') => Some(Message::ApplySearch),
|
||||
_ => {
|
||||
self.search.handle_event(key);
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match key {
|
||||
Key::Char('/') => Some(Message::OpenSearch),
|
||||
|
||||
@@ -187,12 +187,10 @@ impl Browser {
|
||||
}),
|
||||
search: TextField::default()
|
||||
.to_widget(tx.clone())
|
||||
.on_event(|key, s, _| match key {
|
||||
Key::Esc => Some(Message::CloseSearch),
|
||||
Key::Char('\n') => Some(Message::ApplySearch),
|
||||
_ => Some(Message::UpdateSearch {
|
||||
.on_event(|_, s, _| {
|
||||
Some(Message::UpdateSearch {
|
||||
value: s.and_then(|i| i.unwrap_string()).unwrap_or_default(),
|
||||
}),
|
||||
})
|
||||
})
|
||||
.on_update(|state: &State| {
|
||||
TextFieldProps::default()
|
||||
@@ -217,8 +215,17 @@ impl View for Browser {
|
||||
.unwrap_or(&default);
|
||||
|
||||
if props.show_search {
|
||||
self.search.handle_event(key);
|
||||
None
|
||||
match key {
|
||||
Key::Esc => {
|
||||
self.search.reset();
|
||||
Some(Message::CloseSearch)
|
||||
}
|
||||
Key::Char('\n') => Some(Message::ApplySearch),
|
||||
_ => {
|
||||
self.search.handle_event(key);
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match key {
|
||||
Key::Char('/') => Some(Message::OpenSearch),
|
||||
|
||||
@@ -189,12 +189,10 @@ impl Browser {
|
||||
}),
|
||||
search: TextField::default()
|
||||
.to_widget(tx.clone())
|
||||
.on_event(|key, s, _| match key {
|
||||
Key::Esc => Some(Message::CloseSearch),
|
||||
Key::Char('\n') => Some(Message::ApplySearch),
|
||||
_ => Some(Message::UpdateSearch {
|
||||
.on_event(|_, s, _| {
|
||||
Some(Message::UpdateSearch {
|
||||
value: s.and_then(|i| i.unwrap_string()).unwrap_or_default(),
|
||||
}),
|
||||
})
|
||||
})
|
||||
.on_update(|state: &State| {
|
||||
TextFieldProps::default()
|
||||
@@ -219,8 +217,17 @@ impl View for Browser {
|
||||
.unwrap_or(&default);
|
||||
|
||||
if props.show_search {
|
||||
self.search.handle_event(key);
|
||||
None
|
||||
match key {
|
||||
Key::Esc => {
|
||||
self.search.reset();
|
||||
Some(Message::CloseSearch)
|
||||
}
|
||||
Key::Char('\n') => Some(Message::ApplySearch),
|
||||
_ => {
|
||||
self.search.handle_event(key);
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match key {
|
||||
Key::Esc | Key::Ctrl('c') => Some(Message::Exit { selection: None }),
|
||||
|
||||
Reference in New Issue
Block a user