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

catch type error in connection.js to partly cope with issue #10 #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,13 @@ Blockly.Connection.prototype.connect_ = function(childConnection) {

if (this.typeExprEnabled()) {
var rootBlock = parentBlock.getRootBlock();
rootBlock.updateTypeInference();
try {
rootBlock.updateTypeInference();
} catch (e) {
var sourceBlock = this.getSourceBlock();
var mainWorkspace = sourceBlock.workspace.getMainWorkspace();
mainWorkspace.undo(false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

メインワークスペースは、入れ子(お砂場)になったワークスペースの根っこにある部分のワークスペースのことです。つまり、どのお砂場にあるブロックも、持っているメインワークスペースは全て一意です。
動かしたという動作を undo したいのならば、どちらかというと sourceBlock.workspace に対して undo するほうが正しいです。
(全ワークスペースで共通の undo stack を持つように実装するなら話は別ですが)
でもどっちにしても、connect_ の中でこれをやると正しく動きません。reviewに対するコメントに書きます。

}
}

if (event) {
Expand Down