Refactor: modularize codebase into focused modules#6
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extract syntax highlighting, font handling, and preview logic into separate modules for better code organization and maintainability.