Unverified Commit 7339fbf7 authored by Beka Westberg's avatar Beka Westberg Committed by GitHub

Improve "Do It" comments (#2181)

parent 80e1e9d1
......@@ -1623,6 +1623,7 @@ Blockly.Msg.en.switch_language_to_english = {
// Blocklyeditor.js
Blockly.Msg.GENERATE_YAIL = "Generate Yail";
Blockly.Msg.DO_IT = "Do It";
Blockly.Msg.DO_IT_RESULT = "Do It Result:";
Blockly.Msg.DO_IT_DISCONNECTED = 'Do It (Companion not connected)';
Blockly.Msg.CLEAR_DO_IT_ERROR = "Clear Error";
Blockly.Msg.CAN_NOT_DO_IT = "Cannot Do it";
......
......@@ -1115,27 +1115,22 @@ Blockly.ReplMgr.processRetvals = function(responses) {
};
Blockly.ReplMgr.setDoitResult = function(block, value) {
var patt = /Do It Result:.*?\n---\n/m;
var comment = "";
var result = 'Do It Result: ' + value + '\n---\n';
var oldPatt = /Do It Result:.*?\n---\n/m;
var patt = new RegExp(Blockly.Msg.DO_IT_RESULT + '.*?\n---\n');
var result = Blockly.Msg.DO_IT_RESULT + ' ' + value + '\n---\n';
var text = "";
if (block.comment) {
comment = block.comment.getText();
text = block.comment.getText().replace(oldPatt, '');
}
if (!comment) {
comment = result;
if (!text) {
text = result;
} else if (patt.test(text)) { // Already a result there.
text = text.replace(patt, result);
} else {
if (patt.test(comment)) { // Already a doit there!
comment = comment.replace(patt, result);
} else {
comment = result + comment;
}
}
// If we don't set visible to false, the comment
// doesn't always change when it should...
if (block.comment) {
block.comment.setVisible(false);
text = result + text;
}
block.setCommentText(comment);
block.setCommentText(text);
block.comment.setVisible(true);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment