mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 04:58:57 +00:00
Minor optimization in pager_selection_changed
This commit is contained in:
parent
8bb442f135
commit
da0a93b24b
1 changed files with 6 additions and 4 deletions
|
@ -22,6 +22,7 @@ use nix::sys::stat::Mode;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
#[cfg(not(target_has_atomic = "64"))]
|
#[cfg(not(target_has_atomic = "64"))]
|
||||||
use portable_atomic::AtomicU64;
|
use portable_atomic::AtomicU64;
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
@ -3774,18 +3775,19 @@ impl ReaderData {
|
||||||
let mut cursor_pos = self.cycle_cursor_pos;
|
let mut cursor_pos = self.cycle_cursor_pos;
|
||||||
|
|
||||||
let new_cmd_line = match completion {
|
let new_cmd_line = match completion {
|
||||||
None => self.cycle_command_line.clone(),
|
None => Cow::Borrowed(&self.cycle_command_line),
|
||||||
Some(completion) => completion_apply_to_command_line(
|
Some(completion) => Cow::Owned(completion_apply_to_command_line(
|
||||||
&completion.completion,
|
&completion.completion,
|
||||||
completion.flags,
|
completion.flags,
|
||||||
&self.cycle_command_line,
|
&self.cycle_command_line,
|
||||||
&mut cursor_pos,
|
&mut cursor_pos,
|
||||||
false,
|
false,
|
||||||
),
|
)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only update if something changed, to avoid useless edits in the undo history.
|
// Only update if something changed, to avoid useless edits in the undo history.
|
||||||
if new_cmd_line != self.command_line.text() {
|
if new_cmd_line.as_utfstr() != self.command_line.text() {
|
||||||
|
let new_cmd_line = new_cmd_line.into_owned();
|
||||||
self.set_buffer_maintaining_pager(&new_cmd_line, cursor_pos, /*transient=*/ true);
|
self.set_buffer_maintaining_pager(&new_cmd_line, cursor_pos, /*transient=*/ true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue