@@ -297,7 +297,7 @@ def build_update_commands(self, index, added_controls, commands, isolated=False)
297297
298298 n = 0
299299 for tag , a1 , a2 , b1 , b2 in sm .get_opcodes ():
300- if tag == "delete" :
300+ if tag == "delete" or tag == "replace" :
301301 # deleted controls
302302 ids = []
303303 for h in previous_ints [a1 :a2 ]:
@@ -321,6 +321,23 @@ def build_update_commands(self, index, added_controls, commands, isolated=False)
321321 ids .append (ctrl .__uid )
322322 if len (ids ) > 0 :
323323 commands .append (Command (0 , "remove" , ids ))
324+ if tag == "replace" :
325+ # add
326+ for h in current_ints [b1 :b2 ]:
327+ ctrl = hashes [h ]
328+ innerCmds = ctrl ._build_add_commands (
329+ index = index , added_controls = added_controls
330+ )
331+ assert self .__uid is not None
332+ commands .append (
333+ Command (
334+ indent = 0 ,
335+ name = "add" ,
336+ attrs = {"to" : self .__uid , "at" : str (n )},
337+ commands = innerCmds ,
338+ )
339+ )
340+ n += 1
324341 elif tag == "equal" :
325342 # unchanged control
326343 for h in previous_ints [a1 :a2 ]:
@@ -329,30 +346,6 @@ def build_update_commands(self, index, added_controls, commands, isolated=False)
329346 index , added_controls , commands , isolated = ctrl ._is_isolated ()
330347 )
331348 n += 1
332- elif tag == "replace" :
333- ids = []
334- for h in previous_ints [a1 :a2 ]:
335- # delete
336- ctrl = hashes [h ]
337- self ._remove_control_recursively (index , ctrl )
338- ids .append (ctrl .__uid )
339- commands .append (Command (0 , "remove" , ids ))
340- for h in current_ints [b1 :b2 ]:
341- # add
342- ctrl = hashes [h ]
343- innerCmds = ctrl ._build_add_commands (
344- index = index , added_controls = added_controls
345- )
346- assert self .__uid is not None
347- commands .append (
348- Command (
349- indent = 0 ,
350- name = "add" ,
351- attrs = {"to" : self .__uid , "at" : str (n )},
352- commands = innerCmds ,
353- )
354- )
355- n += 1
356349 elif tag == "insert" :
357350 # add
358351 for h in current_ints [b1 :b2 ]:
0 commit comments