1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 21:32:13 +03:00

quickselect: avoid jumping to bottom of viewport when activated

This commit is contained in:
Wez Furlong 2022-05-19 17:03:20 -07:00
parent 39bb8b3f39
commit 55767c69b1
2 changed files with 21 additions and 6 deletions

View File

@ -40,6 +40,7 @@ As features stabilize some brief notes about them will accumulate here.
* 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)
* Quickselect no longer jumps to the bottom of the viewport when activated, allowing you to quickselect within the current viewport region
#### 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

@ -240,7 +240,7 @@ impl QuickSelectOverlay {
let search_row = renderer.compute_search_row();
renderer.dirty_results.add(search_row);
renderer.update_search();
renderer.update_search(true);
Rc::new(QuickSelectOverlay {
renderer: RefCell::new(renderer),
@ -546,7 +546,7 @@ impl QuickSelectRenderable {
self.height = dims.viewport_rows;
let pos = self.result_pos;
self.update_search();
self.update_search(false);
self.result_pos = pos;
}
@ -628,7 +628,7 @@ impl QuickSelectRenderable {
}
}
fn update_search(&mut self) {
fn update_search(&mut self, is_initial_run: bool) {
for idx in self.by_line.keys() {
self.dirty_results.add(*idx);
}
@ -665,9 +665,21 @@ impl QuickSelectRenderable {
let num_results = r.results.len();
if !r.results.is_empty() {
r.activate_match_number(num_results - 1);
match &r.viewport {
Some(y) if is_initial_run => {
r.result_pos = r
.results
.iter()
.position(|result| result.start_y >= *y);
}
_ => {
r.activate_match_number(num_results - 1);
}
}
} else {
r.set_viewport(None);
if !is_initial_run {
r.set_viewport(None);
}
r.clear_selection();
}
}
@ -677,7 +689,9 @@ impl QuickSelectRenderable {
})
.detach();
} else {
self.set_viewport(None);
if !is_initial_run {
self.set_viewport(None);
}
self.clear_selection();
}
}