Skip to content

Conversation

@alexrios
Copy link
Owner

@alexrios alexrios commented Nov 6, 2025

Extract syntax highlighting, font handling, and preview logic into separate modules for better code organization and maintainability.

Extract syntax highlighting, font handling, and preview logic into
separate modules for better code organization and maintainability.

New Modules:
- src/font.zig (87 lines): Font loading and texture caching
- src/preview.zig (240 lines): File preview and detection utilities
- src/syntax_highlight.zig (238 lines): Tree-sitter syntax highlighting

Changes:
- Reduced main.zig from 1823 to 1678 lines (-145 lines)
- Added 50 comprehensive tests across all modules
- Fixed memory leak in font path cleanup
- Simplified build.zig test configuration

Test Coverage:
- preview.zig: 18 tests (line counting, file detection, I/O)
- font.zig: 7 tests (configuration, caching, platform paths)
- syntax_highlight.zig: 6 tests (color mapping, scope detection)
- main.zig: 14 tests (existing core functionality)
- theme.zig: 5 tests (existing theme tests)
Total: 50 tests ensuring safe future refactoring

Benefits:
- Single Responsibility: Each module has clear, focused purpose
- Easier Navigation: Find relevant code quickly by module
- Better Testability: Isolated testing of components
- Improved Maintainability: Changes are localized to modules
- Safe Refactoring: Comprehensive test coverage prevents regressions

All tests pass. No functionality changed, purely organizational.
Keep only the correct usage example and important note about full paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants