You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
state/events.rs or integration with app – event enums and dispatch
Care: Touched by many modules; refactor in small, compile-after-each steps.
3. markdown/widgets.rs (3,838 lines)
Why: Many editable widget types in one file.
Idea: Split by widget kind, e.g. widgets/headings.rs, widgets/lists.rs, widgets/tables.rs, widgets/code.rs, widgets/links.rs, with a thin widgets/mod.rs.
4. editor/ferrite/editor.rs (3,356 lines)
Why: Core editor logic, input, and rendering orchestration in one file.
Idea: Further extract: e.g. input handling (beyond existing input/), high-level render coordination, or “mode” handling (edit vs view) into sibling modules. Keep editor.rs as the main entry that delegates.
5. config/settings.rs (3,235 lines)
Why: Settings definition, validation, shortcuts, and a lot of UI-related options.
Idea: Split by domain: e.g. settings/appearance.rs, settings/editor.rs, settings/files.rs, settings/shortcuts.rs, settings/validation.rs, with a central Settings and mod.rs that composes them.
6. app/mod.rs (2,187 lines)
Why: Already reduced from the old 7,634-line app.rs; still holds a lot of coordination.
Ref:docs/technical/planning/app-rs-refactoring-plan.md – Phase 3 (decompose render_ui) and Phase 4 (ribbon dispatch) are the next levers to shrink this further.
7. ui/terminal_panel.rs (1,927) and ui/settings.rs (1,806)
Why: Large UI modules with many sections and branches.
Idea: Extract sub-views or sections (e.g. terminal: tabs vs splits vs context menus; settings: per-tab or per-section modules) into separate files under ui/terminal_panel/ or ui/settings/ if it improves readability and review size.
What’s Already in Good Shape
app/ – Already split from a single 7,634-line file into ~15 modules; app/mod.rs is the main remaining large chunk.
markdown/mermaid/flowchart/ – Already refactored from a single ~3,600-line file into 12 modules (types, parser, layout/, render/, utils); good template for other big modules.
editor/ferrite/ – Already modular (buffer, cursor, view, history, line_cache, input/, rendering/); editor.rs is the main remaining large file.
Small, focused modules – Many files under ~500 lines (e.g. theme, platform, workers, export, preview, path_utils, error) are in a good place for maintenance.
Suggested Order of Work (if you refactor later)
Markdown editor – Split markdown/editor.rs by responsibility (and optionally align with widgets split).
State – Split state.rs into a small state/ crate or module group with clear boundaries.
Markdown widgets – Split markdown/widgets.rs by widget type.
Ferrite editor – Further trim editor/ferrite/editor.rs by extracting cohesive blocks.
Config – Split config/settings.rs by domain.
App – Continue app plan Phase 3/4 to reduce app/mod.rs.
UI panels – Optionally split ui/terminal_panel.rs and ui/settings.rs if needed for readability or parallel work.
Notes
Line counts are raw lines (including comments and blanks); they reflect size and navigation cost, not necessarily complexity.
Flowchart refactor is the best in-repo example: same behavior, tests passing, much better structure.
No code was changed for this assessment; this document is for planning only.