From 98ace6a1d178b44e050997aff46b2f86a6a1c721 Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Mon, 26 Sep 2022 14:49:07 +0200 Subject: [PATCH] Editing via `esc` does not correctly update node view (#3732) Fixes https://www.pivotaltracker.com/story/show/182926584 https://user-images.githubusercontent.com/1428930/191850310-b52e07ec-d3b8-4f27-b15d-fc0944ce48ab.mp4 # Important Notes [ci no changelog needed] --- app/gui/src/controller/graph.rs | 4 ++-- app/gui/src/presenter/graph/state.rs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/gui/src/controller/graph.rs b/app/gui/src/controller/graph.rs index 7d5b0950fbc4..207def6b2fbd 100644 --- a/app/gui/src/controller/graph.rs +++ b/app/gui/src/controller/graph.rs @@ -842,7 +842,7 @@ impl Handle { /// Sets the given's node expression. #[profile(Debug)] pub fn set_expression(&self, id: ast::Id, expression_text: impl Str) -> FallibleResult { - info!(self.logger, "Setting node {id} expression to `{expression_text.as_ref()}`"); + tracing::info!("Setting node {id} expression to `{}`", expression_text.as_ref()); let new_expression_ast = self.parse_node_expression(expression_text)?; self.set_expression_ast(id, new_expression_ast) } @@ -850,7 +850,7 @@ impl Handle { /// Sets the given's node expression. #[profile(Debug)] pub fn set_expression_ast(&self, id: ast::Id, expression: Ast) -> FallibleResult { - info!(self.logger, "Setting node {id} expression to `{expression.repr()}`"); + tracing::info!("Setting node {id} expression to `{}`", expression.repr()); self.update_definition_ast(|definition| { let mut graph = GraphInfo::from_definition(definition); graph.edit_node(id, expression)?; diff --git a/app/gui/src/presenter/graph/state.rs b/app/gui/src/presenter/graph/state.rs index 1b9655193750..f29027e75ca5 100644 --- a/app/gui/src/presenter/graph/state.rs +++ b/app/gui/src/presenter/graph/state.rs @@ -669,7 +669,10 @@ impl<'a> ViewChange<'a> { expression ); let expression_has_changed = displayed.expression != expression; - expression_has_changed.as_some(ast_id) + expression_has_changed.then(|| { + displayed.expression = expression; + ast_id + }) } }