diff --git a/docs/changelog.md b/docs/changelog.md index f084e6f57..4284cf986 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -33,6 +33,7 @@ As features stabilize some brief notes about them will accumulate here. * Debian packages now register wezterm as an alternative for `x-terminal-emulator`. Thanks to [@xpufx](https://github.com/xpufx)! [#1883](https://github.com/wez/wezterm/pull/1883) * Windows: wezterm will now read the default environment variables from the `HKLM\System\CurrentControlSet\Control\Session Manager\Environment` and `HKCU\Environment` and apply those to the base environment prior to applying `set_environment_variables`. [#1848](https://github.com/wez/wezterm/issues/1848) * [Key Table](config/key-tables.md) lookups will now keep searching the activation stack until a matching assignment is found, allowing for layered key tables. [#993](https://github.com/wez/wezterm/issues/993) +* Search mode's search term is now remembered globally between activations of search mode. [#1912](https://github.com/wez/wezterm/issues/1912) #### Fixed * Flush after replying to XTGETTCAP and DECRQM. [#1850](https://github.com/wez/wezterm/issues/1850) [#1950](https://github.com/wez/wezterm/issues/1950) diff --git a/wezterm-gui/src/overlay/copy.rs b/wezterm-gui/src/overlay/copy.rs index cabb1321d..821073223 100644 --- a/wezterm-gui/src/overlay/copy.rs +++ b/wezterm-gui/src/overlay/copy.rs @@ -12,7 +12,7 @@ use std::cell::{RefCell, RefMut}; use std::collections::HashMap; use std::ops::Range; use std::rc::Rc; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use termwiz::cell::{Cell, CellAttributes}; use termwiz::color::AnsiColor; use termwiz::surface::{CursorVisibility, SequenceNo, SEQ_ZERO}; @@ -24,6 +24,10 @@ use wezterm_term::{ }; use window::{KeyCode as WKeyCode, Modifiers, WindowOps}; +lazy_static::lazy_static! { + static ref SAVED_PATTERN: Mutex = Mutex::new(Pattern::default()); +} + pub struct CopyOverlay { delegate: Rc, render: RefCell, @@ -94,7 +98,11 @@ impl CopyOverlay { height: dims.viewport_rows, last_result_seqno: SEQ_ZERO, last_bar_pos: None, - pattern: params.pattern, + pattern: if params.pattern.is_empty() { + SAVED_PATTERN.lock().unwrap().clone() + } else { + params.pattern + }, editing_search: params.editing_search, result_pos: None, }; @@ -206,6 +214,8 @@ impl CopyRenderable { self.by_line.clear(); self.result_pos.take(); + *SAVED_PATTERN.lock().unwrap() = self.pattern.clone(); + let bar_pos = self.compute_search_row(); self.dirty_results.add(bar_pos); self.last_result_seqno = self.delegate.get_current_seqno();