Merge pull request #38 from javabird25/lossy-description

Use String::from_utf8_lossy() for task description output
This commit is contained in:
Dheepak Krishnamurthy 2020-10-31 09:22:22 -07:00 committed by GitHub
commit 694ea0f351
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -393,10 +393,7 @@ impl TTApp {
let task_id = self.tasks.lock().unwrap()[selected].id().unwrap_or_default(); let task_id = self.tasks.lock().unwrap()[selected].id().unwrap_or_default();
let output = Command::new("task").arg(format!("{}", task_id)).output(); let output = Command::new("task").arg(format!("{}", task_id)).output();
if let Ok(output) = output { if let Ok(output) = output {
let data = String::from_utf8(output.stdout).unwrap_or(format!( let data = String::from_utf8_lossy(&*output.stdout);
"Unable to get description of task with id: {}. Please report as an issue on github.",
task_id
));
let p = Paragraph::new(Text::from(&data[..])).block( let p = Paragraph::new(Text::from(&data[..])).block(
Block::default() Block::default()
.borders(Borders::ALL) .borders(Borders::ALL)