Skip to content

Commit 6bf1d26

Browse files
voedipusedfloreshz
authored andcommitted
fix qalc output parsing
1 parent 7d96476 commit 6bf1d26

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/app.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,9 @@ impl Application for CosmicCalculator {
465465
return Task::batch(tasks);
466466
}
467467

468-
let outcome = String::from_utf8(output.stdout).unwrap_or_default();
468+
let outcome = String::from_utf8(output.stdout)
469+
.unwrap_or_default()
470+
.replace(['\n', '\r'], "");
469471
if outcome.is_empty() {
470472
tracing::error!("Failed to parse qalc output");
471473
tasks.push(self.update(Message::ShowToast(
@@ -474,7 +476,7 @@ impl Application for CosmicCalculator {
474476
return Task::batch(tasks);
475477
};
476478

477-
self.calculator.outcome = outcome.to_string();
479+
self.calculator.outcome = outcome.clone();
478480

479481
let mut history = self.config.history.clone();
480482
history.push(self.calculator.clone());
@@ -491,7 +493,7 @@ impl Application for CosmicCalculator {
491493
.text(self.calculator.expression.clone())
492494
.data(self.calculator.clone());
493495

494-
self.calculator.expression = outcome.to_string();
496+
self.calculator.expression = outcome;
495497
}
496498
Message::Key(modifiers, key) => {
497499
for (key_bind, action) in &self.key_binds {

0 commit comments

Comments
 (0)