1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-21 03:39:16 +03:00

search: save last used search term and restore it

When search mode is activated with an empty pattern, restore
the most recently used search term in any pane.

refs: https://github.com/wez/wezterm/issues/1912
This commit is contained in:
Wez Furlong 2022-05-05 12:12:06 -07:00
parent 2710cefb3e
commit dc0fde7ae0
2 changed files with 13 additions and 2 deletions

View File

@ -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)

View File

@ -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<Pattern> = Mutex::new(Pattern::default());
}
pub struct CopyOverlay {
delegate: Rc<dyn Pane>,
render: RefCell<CopyRenderable>,
@ -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();