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 = { ...@@ -1623,6 +1623,7 @@ Blockly.Msg.en.switch_language_to_english = {
// Blocklyeditor.js // Blocklyeditor.js
Blockly.Msg.GENERATE_YAIL = "Generate Yail"; Blockly.Msg.GENERATE_YAIL = "Generate Yail";
Blockly.Msg.DO_IT = "Do It"; 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.DO_IT_DISCONNECTED = 'Do It (Companion not connected)';
Blockly.Msg.CLEAR_DO_IT_ERROR = "Clear Error"; Blockly.Msg.CLEAR_DO_IT_ERROR = "Clear Error";
Blockly.Msg.CAN_NOT_DO_IT = "Cannot Do it"; Blockly.Msg.CAN_NOT_DO_IT = "Cannot Do it";
......
...@@ -1115,27 +1115,22 @@ Blockly.ReplMgr.processRetvals = function(responses) { ...@@ -1115,27 +1115,22 @@ Blockly.ReplMgr.processRetvals = function(responses) {
}; };
Blockly.ReplMgr.setDoitResult = function(block, value) { Blockly.ReplMgr.setDoitResult = function(block, value) {
var patt = /Do It Result:.*?\n---\n/m; var oldPatt = /Do It Result:.*?\n---\n/m;
var comment = ""; var patt = new RegExp(Blockly.Msg.DO_IT_RESULT + '.*?\n---\n');
var result = 'Do It Result: ' + value + '\n---\n'; var result = Blockly.Msg.DO_IT_RESULT + ' ' + value + '\n---\n';
var text = "";
if (block.comment) { if (block.comment) {
comment = block.comment.getText(); text = block.comment.getText().replace(oldPatt, '');
} }
if (!comment) { if (!text) {
comment = result; text = result;
} else { } else if (patt.test(text)) { // Already a result there.
if (patt.test(comment)) { // Already a doit there! text = text.replace(patt, result);
comment = comment.replace(patt, result);
} else { } else {
comment = result + comment; text = result + text;
}
}
// If we don't set visible to false, the comment
// doesn't always change when it should...
if (block.comment) {
block.comment.setVisible(false);
} }
block.setCommentText(comment); block.setCommentText(text);
block.comment.setVisible(true); 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