Skip to content

Commit

Permalink
fix(search): allow terminating char to clear search term (#1853)
Browse files Browse the repository at this point in the history
* allow terminating char to clear search term

* format code
  • Loading branch information
naosense authored Nov 2, 2022
1 parent 8f293f5 commit f334415
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zellij-server/src/tab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit f334415

Please sign in to comment.