File tree Expand file tree Collapse file tree 5 files changed +7
-7
lines changed
Expand file tree Collapse file tree 5 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -531,7 +531,7 @@ const CALL_PYTHON_FUNCTION = {
531531 getComponents : function ( this : CallPythonFunctionBlock ) : storageModuleContent . Component [ ] {
532532 // Get the list of components whose type matches this.mrcComponentClassName.
533533 const components : storageModuleContent . Component [ ] = [ ] ;
534- const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace ) || Editor . getCurrentEditor ( ) ;
534+ const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace , true /* returnCurrentIfNotFound */ ) ;
535535 if ( editor ) {
536536 let componentsToConsider : storageModuleContent . Component [ ] = [ ] ;
537537 if ( this . mrcMechanismId ) {
@@ -567,7 +567,7 @@ const CALL_PYTHON_FUNCTION = {
567567 } ,
568568 mrcOnLoad : function ( this : CallPythonFunctionBlock ) : void {
569569 // mrcOnLoad is called for each CallPythonFunctionBlock when the blocks are loaded in the blockly workspace.
570- const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace ) || Editor . getCurrentEditor ( ) ;
570+ const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace , true /* returnCurrentIfNotFound */ ) ;
571571 if ( ! editor ) {
572572 return ;
573573 }
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ const COMPONENT = {
127127 * Update the block to reflect the newly loaded extra state.
128128 */
129129 updateBlock_ : function ( this : ComponentBlock ) : void {
130- const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace ) || Editor . getCurrentEditor ( ) ;
130+ const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace , true /* returnCurrentIfNotFound */ ) ;
131131 if ( editor && editor . getModuleType ( ) === storageModule . ModuleType . ROBOT ) {
132132 // Add input sockets for the arguments.
133133 for ( let i = 0 ; i < this . mrcArgs . length ; i ++ ) {
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ const EVENT_HANDLER = {
178178 mrcOnLoad : function ( this : EventHandlerBlock ) : void {
179179 const warnings : string [ ] = [ ] ;
180180
181- const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace ) || Editor . getCurrentEditor ( ) ;
181+ const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace , true /* returnCurrentIfNotFound */ ) ;
182182 if ( editor ) {
183183 if ( this . mrcSenderType === SenderType . ROBOT ) {
184184 // This block is an event handler for a robot event.
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ const MECHANISM = {
178178 // mrcOnLoad is called for each MechanismBlock when the blocks are loaded in the blockly workspace.
179179 const warnings : string [ ] = [ ] ;
180180
181- const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace ) || Editor . getCurrentEditor ( ) ;
181+ const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace , true /* returnCurrentIfNotFound */ ) ;
182182 if ( editor ) {
183183 // Find the mechanism.
184184 let foundMechanism : storageModule . Mechanism | null = null ;
Original file line number Diff line number Diff line change @@ -498,7 +498,7 @@ export class Editor {
498498 throw new Error ( 'getMethodsFromMechanism: mechanism not found: ' + mechanism . className ) ;
499499 }
500500
501- public static getEditorForBlocklyWorkspace ( workspace : Blockly . Workspace ) : Editor | null {
501+ public static getEditorForBlocklyWorkspace ( workspace : Blockly . Workspace , opt_returnCurrentIfNotFound ?: boolean ) : Editor | null {
502502 if ( workspace . id in Editor . workspaceIdToEditor ) {
503503 return Editor . workspaceIdToEditor [ workspace . id ] ;
504504 }
@@ -511,7 +511,7 @@ export class Editor {
511511 return Editor . workspaceIdToEditor [ rootWorkspace . id ] ;
512512 }
513513
514- return null ;
514+ return opt_returnCurrentIfNotFound ? Editor . currentEditor : null ;
515515 }
516516
517517 public static getEditorForBlocklyWorkspaceId ( workspaceId : string ) : Editor | null {
You can’t perform that action at this time.
0 commit comments