Split editor.rs into smaller modules
#55352
Replies: 3 comments 23 replies
-
|
I'm not personally interested in working on this (but I don't speak for everyone). |
Beta Was this translation helpful? Give feedback.
-
|
I am not interested to break it all at once (yet), as it will create a lot of conflicts with the existing PRs. Yet, already trying to place the new code into separate modules already, e.g. editor.rs: https://github.com/zed-industries/zed/pull/54100/changes#diff-a3da3181e4ab4f73aa1697d7b6dc0caa0c17b2a187fb83b076dfc0234ec91f54 Overall, would be nice to have both I see the way forward with small, incremental, split offs of the existing code into modules, one by one. On a related note, |
Beta Was this translation helpful? Give feedback.
-
Yes, incremental splits is possible and a good way forward. We can create an issue (story-like) for the incremental split, wdyt? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
crates/editor/src/editor.rsis ~30k lines and growing (I remember it was around 20k in September 2025 😅 ). At that size GitHub stops syntax-highlighting it, every diff lands in one file, and it's hard to tell whether a change is touching input, completions, or rendering glue.Editoris central for real reasons (GPUI entity, view, input handler, workspace item, event source), so a semantic refactor is genuinely hard, but the file size is making review and contribution worse than it needs to be.I pushed a branch that takes the smallest possible step: compare link. This is just a mechanical split into a different files and public API is unchanged. Contiguous
impl Editorblocks moved into child modules undercrates/editor/src/editor/, this is how it looks in the file tree:After the split:
editor.rs: 16,938 (from 30,482)editor/navigation.rs: 5,627 — already too big, obvious next splitelement.rs: 14,089, untouched (but should be splitted as well)editor_tests.rs: 37,516, untouchedI didn't try to split
Editorinto separate runtime objects. Most methods need some mix of&mut Editor,&mut Window,&mut Context<Editor>, snapshots,cx.notify(),cx.emit(...), and async tasks that upgrade aWeakEntity<Editor>later, so decomposing that into independent components hits borrow and lifecycle issues fast.Would maintainers take a mechanical split like this as a first step? If so, the natural follow-up is the same breaking up of
element.rsfile which is also super huge ATMcc @ConradIrwin
Beta Was this translation helpful? Give feedback.
All reactions