This pull request addresses the issue reported in #9, where the :TWCenter command centers the current line instead of the entire code block, particularly in PHP files.
Summary of Changes:
Enhanced center_block_and_cursor Function:
Improved logic to correctly identify and center the code block.
Added detailed debug output for better troubleshooting of node identification.
Ensured edge cases near the bottom of the file are handled correctly.
Updated get_expand_root Function:
Integrated center_block_config to accurately determine significant nodes for centering.
Refactored is_significant_block Function:
Leveraged center_block_config for comprehensive identification of significant nodes.
Added debug output for better visibility of node types.
Added New Node Types:
Included declaration_list and other relevant nodes in center_block_config to ensure all significant blocks are considered.
Removed Debug Print Statements:
Cleaned up code by removing unnecessary debug print statements.
Commits:
feat(commands): Correctly center code block even when near bottom of the file.
fix: Improve center_block_and_cursor function for better PHP block handling.
fix: Improve center_block_and_cursor function for better PHP block handling.
fix: Improve get_expand_root logic for better PHP block handling.
feat(center_block_config): Add declaration_list to node list.
refactor(center_block_and_cursor): Add new nodes.
feat(center_block_config): Add new node.
style(commands): Remove debug print statements.
docs: Update CHANGELOG.md for v0.4.24 and remove duplicate entries.
Verified that the :TWCenter command now correctly centers the entire code block in PHP files.
Ensured that the function works as expected with various node types and edge cases.
This pull request improves the reliability and functionality of the :TWCenter command in Neovim, particularly for PHP files, ensuring that the correct code block is centered as intended.
Description:
This pull request addresses the issue reported in #9, where the
:TWCenter
command centers the current line instead of the entire code block, particularly in PHP files.Summary of Changes:
Enhanced
center_block_and_cursor
Function:Updated
get_expand_root
Function:center_block_config
to accurately determine significant nodes for centering.Refactored
is_significant_block
Function:center_block_config
for comprehensive identification of significant nodes.Added New Node Types:
declaration_list
and other relevant nodes incenter_block_config
to ensure all significant blocks are considered.Removed Debug Print Statements:
Commits:
center_block_and_cursor
function for better PHP block handling.center_block_and_cursor
function for better PHP block handling.get_expand_root
logic for better PHP block handling.declaration_list
to node list.CHANGELOG.md
for v0.4.24 and remove duplicate entries.Files Changed:
Contributors:
Related Issues:
Testing:
:TWCenter
command now correctly centers the entire code block in PHP files.This pull request improves the reliability and functionality of the
:TWCenter
command in Neovim, particularly for PHP files, ensuring that the correct code block is centered as intended.