fix(search): allow terminating char to clear search term (#1853)

* allow terminating char to clear search term

* format code
This commit is contained in:
哇呜哇呜呀咦耶 2022-11-02 21:35:23 +08:00 committed by GitHub
parent 8f293f584f
commit f334415d57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2650,8 +2650,10 @@ impl Tab {
pub fn update_search_term(&mut self, buf: Vec<u8>, client_id: ClientId) -> Result<()> {
if let Some(active_pane) = self.get_active_pane_or_floating_pane_mut(client_id) {
// It only allows printable unicode, delete and backspace keys.
let is_updatable = buf.iter().all(|u| matches!(u, 0x20..=0x7E | 0x08 | 0x7F));
// It only allows terminating char(\0), printable unicode, delete and backspace keys.
let is_updatable = buf
.iter()
.all(|u| matches!(u, 0x00 | 0x20..=0x7E | 0x08 | 0x7F));
if is_updatable {
let s = str::from_utf8(&buf).with_context(|| {
format!("failed to update search term to '{buf:?}' for client {client_id}")