zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
34.48k stars 1.71k forks source link

Refactor Windows platform implementation #11393

Closed JunkuiZhang closed 1 week ago

JunkuiZhang commented 2 weeks ago

This aligns the Windows platform implementation with a code style similar to macOS platform, eliminating most of the Cells and Mutexes. This adjustment facilitates potential future porting to a multi-threaded implementation if required.

Overall, this PR made the following changes: it segregated all member variables in WindowsPlatform and WindowsWindow, grouping together variables that remain constant throughout the entire app lifecycle, while placing variables that may change during app runtime into RefCell.

Edit: During the code refactoring process, a bug was also fixed.

Before: Close window when file has changed, nothing happen:

https://github.com/zed-industries/zed/assets/14981363/0bcda7c1-808c-4b36-8953-a3a3365a314e

After: Now should_close callback is properly handled

https://github.com/zed-industries/zed/assets/14981363/c8887b72-9a0b-42ad-b9ab-7d0775d843f5

Release Notes:

mikayla-maki commented 1 week ago

Love to see this kind of simplification!

It seems the transparency work has caused some non-trivial conflicts, once those are fixed I'd be happy to merge this :)

mikayla-maki commented 1 week ago

Thank you!