aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-07-24 08:48:45 +0000
committerBlaž Hrastnik2021-07-26 02:19:33 +0000
commit63e54e30a74bb0d1d782877ddbbcf95f2817d061 (patch)
tree39be3b1e809d4c85c6a7bd132c240e854de985bf /helix-core
parent29cefa1be860e38a11347f0798159e0f4ddfe173 (diff)
Implement in-memory prompt history
Implementation is similar to kakoune: we store the entries into a register.
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/register.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/helix-core/src/register.rs b/helix-core/src/register.rs
index cc881a17..c3e6652e 100644
--- a/helix-core/src/register.rs
+++ b/helix-core/src/register.rs
@@ -22,13 +22,17 @@ impl Register {
self.name
}
- pub fn read(&self) -> &Vec<String> {
+ pub fn read(&self) -> &[String] {
&self.values
}
pub fn write(&mut self, values: Vec<String>) {
self.values = values;
}
+
+ pub fn push(&mut self, value: String) {
+ self.values.push(value);
+ }
}
/// Currently just wraps a `HashMap` of `Register`s
@@ -42,11 +46,7 @@ impl Registers {
self.inner.get(&name)
}
- pub fn get_mut(&mut self, name: char) -> Option<&mut Register> {
- self.inner.get_mut(&name)
- }
-
- pub fn get_or_insert(&mut self, name: char) -> &mut Register {
+ pub fn get_mut(&mut self, name: char) -> &mut Register {
self.inner
.entry(name)
.or_insert_with(|| Register::new(name))
@@ -57,7 +57,7 @@ impl Registers {
.insert(name, Register::new_with_values(name, values));
}
- pub fn read(&self, name: char) -> Option<&Vec<String>> {
+ pub fn read(&self, name: char) -> Option<&[String]> {
self.get(name).map(|reg| reg.read())
}
}