This PR addresses the error attempt to call global 'get_expand_root' (a nil value) encountered when running the TWTop or TWBottom commands. The error occurred because the get_expand_root function was defined locally within the center_block_and_cursor function, making it unavailable to other functions like move_to_top_of_block and move_to_bottom_of_block.
Changes Made
Moved the is_significant_block and get_expand_root helper functions outside of the specific functions, defining them at the top of commands.lua to ensure they are globally accessible within the module.
Updated the center_block_and_cursor, move_to_top_of_block, and move_to_bottom_of_block functions to use the globally defined get_expand_root function.
Impact
This change ensures that the get_expand_root function is accessible to all functions that need it, preventing the nil value error and improving the reliability of the TWTop and TWBottom commands.
Enhances the modularity and maintainability of the code by properly organizing helper functions.
Testing
Verified that the TWTop and TWBottom commands now execute without errors.
Ensured that the center_block_and_cursor function continues to work as expected with the refactored helper functions.
Additional Notes
No changes were made to the existing functionality or logic of the helper functions. They were simply relocated to be globally accessible.
Description
This PR addresses the error attempt to call global 'get_expand_root' (a nil value) encountered when running the TWTop or TWBottom commands. The error occurred because the get_expand_root function was defined locally within the center_block_and_cursor function, making it unavailable to other functions like move_to_top_of_block and move_to_bottom_of_block.
Changes Made
Moved the is_significant_block and get_expand_root helper functions outside of the specific functions, defining them at the top of commands.lua to ensure they are globally accessible within the module. Updated the center_block_and_cursor, move_to_top_of_block, and move_to_bottom_of_block functions to use the globally defined get_expand_root function.
Impact
This change ensures that the get_expand_root function is accessible to all functions that need it, preventing the nil value error and improving the reliability of the TWTop and TWBottom commands. Enhances the modularity and maintainability of the code by properly organizing helper functions.
Testing
Verified that the TWTop and TWBottom commands now execute without errors. Ensured that the center_block_and_cursor function continues to work as expected with the refactored helper functions.
Additional Notes
No changes were made to the existing functionality or logic of the helper functions. They were simply relocated to be globally accessible.
Issue Reference
Closes #8