Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #7502 #7503

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions helix-core/src/register.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Register {
name: char,
values: Vec<String>,
@@ -36,9 +36,9 @@ impl Register {
}

/// Currently just wraps a `HashMap` of `Register`s
#[derive(Debug, Default)]
#[derive(Debug, Clone, Default)]
pub struct Registers {
inner: HashMap<char, Register>,
pub inner: HashMap<char, Register>,
}

impl Registers {
29 changes: 28 additions & 1 deletion helix-view/src/info.rs
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ impl Info {
.map(|(ch, reg)| {
let content = reg
.read()
.get(0)
.last()
.and_then(|s| s.lines().next())
.unwrap_or_default();
(ch.to_string(), content)
@@ -73,3 +73,30 @@ impl Info {
infobox
}
}

#[cfg(test)]
mod tests {
use super::*;
use helix_core::register::Register;
use once_cell::sync::Lazy;

const REGISTER_VALUE_1_MOCK: &str = "value_1";
const REGISTER_VALUE_2_MOCK: &str = "value_2";
static REGISTERS_MOCK: Lazy<Registers> = Lazy::new(|| Registers {
inner: [(
'/',
Register::new_with_values('/', vec![REGISTER_VALUE_1_MOCK.to_string()]),
)]
.into(),
});

#[test]
fn infobox_shows_latest_value() {
let mut registers = (*REGISTERS_MOCK).clone();
registers.push('/', REGISTER_VALUE_2_MOCK.to_string());

assert!(Info::from_registers(&registers)
.text
.contains(REGISTER_VALUE_2_MOCK));
}
}