fix(boards): 修复xpython下变量名大小写不敏感

This commit is contained in:
王立帮
2025-10-19 19:16:12 +08:00
parent d105bf68ec
commit 6b1bd254f5
3 changed files with 3 additions and 9 deletions

View File

@@ -214,18 +214,15 @@ export const lists_zip = {
this.setMutator(new Blockly.icons.MutatorIcon(['lists_zip_item'], this)); this.setMutator(new Blockly.icons.MutatorIcon(['lists_zip_item'], this));
this.setTooltip(Blockly.Msg.MIXLY_PYTHON_LISTS_ZIP_TOOLTIP); this.setTooltip(Blockly.Msg.MIXLY_PYTHON_LISTS_ZIP_TOOLTIP);
}, },
mutationToDom: function () { mutationToDom: function () {
var container = document.createElement('mutation'); var container = document.createElement('mutation');
container.setAttribute('items', this.itemCount_); container.setAttribute('items', this.itemCount_);
return container; return container;
}, },
domToMutation: function (xmlElement) { domToMutation: function (xmlElement) {
this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10); this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
this.updateShape_(); this.updateShape_();
}, },
decompose: function (workspace) { decompose: function (workspace) {
var containerBlock = var containerBlock =
workspace.newBlock('lists_zip_container'); workspace.newBlock('lists_zip_container');
@@ -239,7 +236,6 @@ export const lists_zip = {
} }
return containerBlock; return containerBlock;
}, },
compose: function (containerBlock) { compose: function (containerBlock) {
var itemBlock = containerBlock.getInputTargetBlock('STACK'); var itemBlock = containerBlock.getInputTargetBlock('STACK');
// Count number of inputs. // Count number of inputs.
@@ -260,7 +256,6 @@ export const lists_zip = {
} }
} }
}, },
saveConnections: function (containerBlock) { saveConnections: function (containerBlock) {
var itemBlock = containerBlock.getInputTargetBlock('STACK'); var itemBlock = containerBlock.getInputTargetBlock('STACK');
var i = 0; var i = 0;
@@ -272,7 +267,6 @@ export const lists_zip = {
itemBlock.nextConnection.targetBlock(); itemBlock.nextConnection.targetBlock();
} }
}, },
updateShape_: function () { updateShape_: function () {
// Delete everything. // Delete everything.
if (this.getInput('EMPTY')) { if (this.getInput('EMPTY')) {

View File

@@ -117,7 +117,7 @@ class Names {
name = varName; name = varName;
} }
} }
var normalized = name.toLowerCase() + '_' + type; var normalized = name + '_' + type;
var isVarType = type == Variables.NAME_TYPE || var isVarType = type == Variables.NAME_TYPE ||
type == Names.DEVELOPER_VARIABLE_TYPE; type == Names.DEVELOPER_VARIABLE_TYPE;

View File

@@ -56,7 +56,7 @@ Variables.allVariables = function (root) {
var varName = blockVariables[y]; var varName = blockVariables[y];
// Variable name may be null if the block is only half-built. // Variable name may be null if the block is only half-built.
if (varName) { if (varName) {
variableHash[varName.toLowerCase()] = varName; variableHash[varName] = varName;
} }
} }
} }
@@ -215,7 +215,7 @@ Variables.generateUniqueName = function (workspace) {
while (!newName) { while (!newName) {
var inUse = false; var inUse = false;
for (var i = 0; i < variableList.length; i++) { for (var i = 0; i < variableList.length; i++) {
if (variableList[i].toLowerCase() == potName) { if (variableList[i] == potName) {
// This potential name is already used. // This potential name is already used.
inUse = true; inUse = true;
break; break;