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 TUI channel panics #63

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
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
73 changes: 46 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name = "nu_plugin_explore"
[dependencies]
anyhow = "1.0.73"
crossterm = "0.27.0"
nuon = { git = "https://github.com/nushell/nushell", rev = "2595f31541554c6d8602ebebc9dffbc4dd29dd89", package = "nuon" }
nu-plugin = { git = "https://github.com/nushell/nushell", rev = "2595f31541554c6d8602ebebc9dffbc4dd29dd89", package = "nu-plugin" }
nu-protocol = { git = "https://github.com/nushell/nushell", rev = "2595f31541554c6d8602ebebc9dffbc4dd29dd89", package = "nu-protocol", features = ["plugin"] }
nuon = { git = "https://github.com/nushell/nushell", tag = "0.93.0", package = "nuon" }
nu-plugin = { git = "https://github.com/nushell/nushell", tag = "0.93.0", package = "nu-plugin" }
nu-protocol = { git = "https://github.com/nushell/nushell", tag = "0.93.0", package = "nu-protocol", features = ["plugin"] }
ratatui = "0.26.1"
url = "2.4.0"

Expand All @@ -20,4 +20,4 @@ bench = false
[package]
edition = "2021"
name = "nu_plugin_explore"
version = "0.92.3-2595f31541554c6d8602ebebc9dffbc4dd29dd89"
version = "0.93.0"
2 changes: 1 addition & 1 deletion nupm.nuon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
name: nu_plugin_explore,
version: "0.92.3-2595f31541554c6d8602ebebc9dffbc4dd29dd89"
version: "0.93.0",
description: "A fast structured data explorer for Nushell.",
license: LICENSE,
type: custom
Expand Down
8 changes: 5 additions & 3 deletions src/nu/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ pub(crate) fn is_table(value: &Value) -> Table {
let mut rows = Vec::new();
for (i, val) in vals.iter().enumerate() {
match val.get_type() {
Type::Record(fields) => {
rows.push(fields.into_iter().collect::<HashMap<String, Type>>())
}
Type::Record(fields) => rows.push(
Vec::from(fields)
.into_iter()
.collect::<HashMap<String, Type>>(),
),
t => return Table::RowNotARecord(i, t),
};
}
Expand Down
10 changes: 7 additions & 3 deletions src/tui/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ impl EventHandler {
.unwrap_or(tick_rate);

if event::poll(timeout).expect("no events available") {
match event::read().expect("unable to read event") {
let result = match event::read().expect("unable to read event") {
CrosstermEvent::Key(e) => sender.send(Event::Key(e)),
CrosstermEvent::Mouse(e) => sender.send(Event::Mouse(e)),
CrosstermEvent::Resize(w, h) => sender.send(Event::Resize(w, h)),
_ => Ok(()),
};
if result.is_err() {
break;
}
.expect("failed to send terminal event")
}

if last_tick.elapsed() >= tick_rate {
sender.send(Event::Tick).expect("failed to send tick event");
if sender.send(Event::Tick).is_err() {
break;
}
last_tick = Instant::now();
}
}
Expand Down
Loading