Merge pull request #278 from nathan/rename-variable-fix-layout

Fixed blocks not resizing when renaming variables
This commit is contained in:
Shane M. Clements 2014-06-18 12:02:28 +02:00
commit 35b5563bb7
2 changed files with 10 additions and 3 deletions

View file

@ -693,7 +693,10 @@ public class BlockMenus implements DragClient {
}
if (blockArg != null) blockArg.setArgValue(newName);
if (block != null) {
if (block.op == Specs.GET_VAR) block.setSpec(newName);
if (block.op == Specs.GET_VAR) {
block.setSpec(newName);
block.fixExpressionLayout();
}
}
Scratch.app.setSaveNeeded();
app.updatePalette();

View file

@ -612,8 +612,12 @@ public class ScratchRuntime {
private function updateVarRefs(oldName:String, newName:String, owner:ScratchObj):void {
// Change the variable name in all blocks that use it.
for each (var b:Block in allUsesOfVariable(oldName, owner)) {
if (b.op == Specs.GET_VAR) b.setSpec(newName);
else b.args[0].setArgValue(newName);
if (b.op == Specs.GET_VAR) {
b.setSpec(newName);
b.fixExpressionLayout();
} else {
b.args[0].setArgValue(newName);
}
}
}