Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Fix expression changing during editing #1743

Merged
merged 4 commits into from
Jul 30, 2021
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ these updates be shipped in a stable release before the end of the year.
details in
[the engine release notes](https://github.com/enso-org/enso/blob/main/RELEASES.md).

<br/>![Bug Fixes](/docs/assets/tags/bug_fixes.svg)

#### Visual Environment

- [Fixed a bug where edited node expression was sometimes altered.][1743]. When
editing node expression, the changes were occasionally reverted, or the
grayed-out parameter names were added to the actual expression.

<br/>

[1700]: https://github.com/enso-org/ide/pull/1700
[1726]: https://github.com/enso-org/ide/pull/1726
[1743]: https://github.com/enso-org/ide/pull/1743

# Enso 2.0.0-alpha.10 (2021-07-23)

Expand Down
6 changes: 4 additions & 2 deletions src/rust/ide/src/ide/integration/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,14 @@ impl Model {
};
let expression_changed =
!self.expression_views.borrow().get(&id).contains(&&code_and_trees);
if expression_changed {
let node_is_being_edited = self.view.graph().frp.node_being_edited.value().contains(&id);
if expression_changed && !node_is_being_edited {
for sub_expression in node.info.ast().iter_recursive() {
if let Some(expr_id) = sub_expression.id {
self.node_view_by_expression.borrow_mut().insert(expr_id,id);
}
}
info!(self.logger, "Refreshing node {id:?} expression");
self.view.graph().frp.input.set_node_expression.emit(&(id,code_and_trees.clone()));
self.expression_views.borrow_mut().insert(id,code_and_trees);
}
Expand Down Expand Up @@ -1338,7 +1340,7 @@ impl Model {
Ok(())
},
Err(err) => {
self.view.graph().frp.remove_node.emit(displayed_id);
self.view.graph().frp.remove_node(displayed_id);
Err(err)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use span_tree::traits::*;
// === Expression ===
// ==================

#[derive(Clone,Default,Eq,PartialEq)]
#[derive(Clone,Debug,Default,Eq,PartialEq)]
pub struct Expression {
pub pattern : Option<String>,
pub code : String,
Expand All @@ -30,9 +30,9 @@ impl Expression {
}
}

impl Debug for Expression {
impl Display for Expression {
fn fmt(&self, f:&mut fmt::Formatter<'_>) -> fmt::Result {
write!(f,"Expression({})",self.code)
Display::fmt(&self.code,f)
}
}

Expand Down