avoid exposing internals of register.rs

pull/9143/head
Ingrid 10 months ago
parent e8baf4bcb5
commit 1ae19d9171

@ -88,9 +88,13 @@ fn read_reg_history(filepath: PathBuf) -> Vec<String> {
} }
pub fn read_command_history() -> Vec<String> { pub fn read_command_history() -> Vec<String> {
read_reg_history(command_histfile()) let mut hist = read_reg_history(command_histfile());
hist.reverse();
hist
} }
pub fn read_search_history() -> Vec<String> { pub fn read_search_history() -> Vec<String> {
read_reg_history(search_histfile()) let mut hist = read_reg_history(search_histfile());
hist.reverse();
hist
} }

@ -169,13 +169,13 @@ impl Application {
#[cfg(not(feature = "integration"))] #[cfg(not(feature = "integration"))]
editor editor
.registers .registers
.write_unreversed(':', session::read_command_history()) .write(':', session::read_command_history())
// TODO: do something about this unwrap // TODO: do something about this unwrap
.unwrap(); .unwrap();
#[cfg(not(feature = "integration"))] #[cfg(not(feature = "integration"))]
editor editor
.registers .registers
.write_unreversed('/', session::read_search_history()) .write('/', session::read_search_history())
// TODO: do something about this unwrap // TODO: do something about this unwrap
.unwrap(); .unwrap();

@ -104,29 +104,6 @@ impl Registers {
} }
} }
pub fn write_unreversed(&mut self, name: char, values: Vec<String>) -> Result<()> {
match name {
'_' => Ok(()),
'#' | '.' | '%' => Err(anyhow::anyhow!("Register {name} does not support writing")),
'*' | '+' => {
self.clipboard_provider.set_contents(
values.join(NATIVE_LINE_ENDING.as_str()),
match name {
'+' => ClipboardType::Clipboard,
'*' => ClipboardType::Selection,
_ => unreachable!(),
},
)?;
self.inner.insert(name, values);
Ok(())
}
_ => {
self.inner.insert(name, values);
Ok(())
}
}
}
pub fn push(&mut self, name: char, mut value: String) -> Result<()> { pub fn push(&mut self, name: char, mut value: String) -> Result<()> {
match name { match name {
'_' => Ok(()), '_' => Ok(()),

Loading…
Cancel
Save