File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -372,6 +372,7 @@ define([
372372 if ( OptionComponent ) {
373373 let taskState = menuState . taskState ;
374374 let blockState = menuState . blockState ;
375+ let tmpState = menuState . tmpState ;
375376 let state = {
376377 ...taskState ,
377378 config : menuConfig
@@ -386,9 +387,14 @@ define([
386387 parentBlock = newBlock ; // set parent block of created block
387388 } else {
388389 if ( prevBlock != null && ! newBlock . isGroup ) {
389- newBlock . setDepth ( prevBlock . getChildDepth ( ) ) ;
390+ let newDepth = prevBlock . getChildDepth ( ) ;
391+ if ( tmpState && tmpState . relativeDepth ) {
392+ newDepth = parentBlock . getChildDepth ( ) + tmpState . relativeDepth ;
393+ }
394+ newBlock . setDepth ( newDepth ) ;
390395 }
391396 }
397+ vpLog . display ( VP_LOG_TYPE . DEVELOP , 'new block ' + position + ' with depth ' + newBlock . depth ) ;
392398 prevBlock = newBlock ;
393399 } else {
394400 // add to task list
@@ -485,10 +491,42 @@ define([
485491 }
486492 ]
487493 break ;
494+ case 'lgCtrl_try' :
495+ childBlocks = [
496+ {
497+ menuId : 'lgCtrl_pass' ,
498+ menuState : {
499+ blockState : {
500+ isGroup : false
501+ }
502+ }
503+ } ,
504+ {
505+ menuId : 'lgCtrl_except' ,
506+ menuState : {
507+ blockState : {
508+ isGroup : false
509+ } ,
510+ tmpState : {
511+ relativeDepth : - 1
512+ }
513+ }
514+ } ,
515+ {
516+ menuId : 'lgCtrl_pass' ,
517+ menuState : {
518+ blockState : {
519+ isGroup : false
520+ }
521+ }
522+ }
523+
524+ ] ;
525+ break ;
526+ break ;
488527 case 'lgCtrl_for' :
489528 case 'lgCtrl_while' :
490529 case 'lgCtrl_if' :
491- case 'lgCtrl_try' :
492530 case 'lgCtrl_elif' :
493531 case 'lgCtrl_except' :
494532 case 'lgCtrl_else' :
Original file line number Diff line number Diff line change @@ -768,6 +768,10 @@ define([
768768 if ( elseBlock . length > 0 ) {
769769 this . removeBlock ( elseBlock [ 0 ] ) ;
770770 }
771+ // focus it
772+ setTimeout ( function ( ) {
773+ block . focusItem ( ) ;
774+ } , 100 ) ;
771775 }
772776 }
773777
@@ -800,6 +804,10 @@ define([
800804 if ( finallyBlock ) {
801805 this . removeBlock ( finallyBlock ) ;
802806 }
807+ // focus it
808+ setTimeout ( function ( ) {
809+ block . focusItem ( ) ;
810+ } , 100 ) ;
803811 }
804812 }
805813
You can’t perform that action at this time.
0 commit comments