Skip to content

Commit

Permalink
render types between list and attrset properly
Browse files Browse the repository at this point in the history
  • Loading branch information
bluskript committed Apr 11, 2024
1 parent c542234 commit 5561136
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ pub enum RunningState {
#[derive(Debug, Clone)]
pub struct ListData {
pub cursor: usize,
pub list_type: String,
pub list: Vec<String>,
}

Expand Down Expand Up @@ -290,10 +291,12 @@ impl From<NixValue> for PathData {
NixValue::Path(p) => PathData::Path(p),
NixValue::Null => PathData::Null,
NixValue::Attrs(attrs) => PathData::List(ListData {
list_type: "Attrset".to_string(),
cursor: 0,
list: attrs,
}),
NixValue::List(size) => PathData::List(ListData {
list_type: "List".to_string(),
cursor: 0,
list: (0..size).map(|i| format!("{}", i)).collect(),
}),
Expand All @@ -306,7 +309,7 @@ impl From<NixValue> for PathData {
impl PathData {
pub fn get_type(&self) -> String {
match self {
PathData::List(_) => "List",
PathData::List(data) => data.list_type.as_str(),
PathData::Thunk => "Thunk",
PathData::Int(_) => "Int",
PathData::Float(_) => "Float",
Expand Down

0 comments on commit 5561136

Please sign in to comment.