Mark TODOs and prep for merging main

Mikayla created

Change summary

Cargo.toml                                       |  2 
crates/gpui/screenshot.png                       |  0 
crates/gpui/src/platform/linux/blade_belt.rs     |  4 +-
crates/gpui/src/platform/linux/blade_renderer.rs |  2 
crates/gpui/src/platform/linux/dispatcher.rs     |  2 
crates/gpui/src/platform/linux/platform.rs       | 15 +++++++-
crates/gpui/src/platform/linux/text_system.rs    | 28 ++++++++++++++++-
crates/gpui/src/platform/linux/window.rs         | 22 ++++++++++++++
crates/gpui/src/platform/test/platform.rs        |  6 +++
crates/gpui/src/platform/test/text_system.rs     |  1 
crates/project/src/terminals.rs                  |  4 +-
crates/zed/src/languages.rs                      |  3 +
crates/zed/src/main.rs                           |  3 +
13 files changed, 77 insertions(+), 15 deletions(-)

Detailed changes

Cargo.toml 🔗

@@ -185,7 +185,7 @@ wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "v16.0.
 split-debuginfo = "unpacked"
 debug = "limited"
 
-# TODO - Remove this
+# todo!(linux) - Remove this
 [profile.dev.package.blade-graphics]
 split-debuginfo = "off"
 debug = "full"

crates/gpui/src/platform/linux/blade_belt.rs 🔗

@@ -75,11 +75,11 @@ impl BladeBelt {
         chunk.into()
     }
 
-    //Note: assuming T: bytemuck::Zeroable
+    //todo!(linux): enforce T: bytemuck::Zeroable
     pub fn alloc_data<T>(&mut self, data: &[T], gpu: &gpu::Context) -> gpu::BufferPiece {
         assert!(!data.is_empty());
         let type_alignment = mem::align_of::<T>() as u64;
-        assert_eq!(
+        debug_assert_eq!(
             self.desc.alignment % type_alignment,
             0,
             "Type alignment {} is too big",

crates/gpui/src/platform/linux/blade_renderer.rs 🔗

@@ -411,7 +411,7 @@ impl BladeRenderer {
                     }
                     PrimitiveBatch::Paths(paths) => {
                         let mut encoder = pass.with(&self.pipelines.paths);
-                        //TODO: group by texture ID
+                        //todo!(linux): group by texture ID
                         for path in paths {
                             let tile = &self.path_tiles[&path.id];
                             let tex_info = self.atlas.get_texture_info(tile.texture_id);

crates/gpui/src/platform/linux/dispatcher.rs 🔗

@@ -90,7 +90,7 @@ impl PlatformDispatcher for LinuxDispatcher {
     fn dispatch_on_main_thread(&self, runnable: Runnable) {
         self.main_sender.send(runnable).unwrap();
         // Send a message to the invisible window, forcing
-        // tha main loop to wake up and dispatch the runnable.
+        // the main loop to wake up and dispatch the runnable.
         self.xcb_connection.send_request(&x::SendEvent {
             propagate: false,
             destination: x::SendEventDest::Window(self.x_listener_window),

crates/gpui/src/platform/linux/platform.rs 🔗

@@ -170,14 +170,19 @@ impl Platform for LinuxPlatform {
         self.state.lock().quit_requested = true;
     }
 
+    //todo!(linux)
     fn restart(&self) {}
 
+    //todo!(linux)
     fn activate(&self, ignoring_other_apps: bool) {}
 
+    //todo!(linux)
     fn hide(&self) {}
 
+    //todo!(linux)
     fn hide_other_apps(&self) {}
 
+    //todo!(linux)
     fn unhide_other_apps(&self) {}
 
     fn displays(&self) -> Vec<Rc<dyn PlatformDisplay>> {
@@ -199,6 +204,7 @@ impl Platform for LinuxPlatform {
         )))
     }
 
+    //todo!(linux)
     fn active_window(&self) -> Option<AnyWindowHandle> {
         None
     }
@@ -324,6 +330,7 @@ impl Platform for LinuxPlatform {
         unimplemented!()
     }
 
+    //todo!(linux)
     fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap) {}
 
     fn local_timezone(&self) -> UtcOffset {
@@ -334,14 +341,16 @@ impl Platform for LinuxPlatform {
         unimplemented!()
     }
 
+    //todo!(linux)
     fn set_cursor_style(&self, style: CursorStyle) {}
 
-    fn should_auto_hide_scrollbars(&self) -> bool {
-        false
-    }
+    //todo!(linux)
+    fn should_auto_hide_scrollbars(&self) -> bool {}
 
+    //todo!(linux)
     fn write_to_clipboard(&self, item: ClipboardItem) {}
 
+    //todo!(linux)
     fn read_from_clipboard(&self) -> Option<ClipboardItem> {
         None
     }

crates/gpui/src/platform/linux/text_system.rs 🔗

@@ -29,6 +29,7 @@ struct LinuxTextSystemState {
     postscript_names_by_font_id: HashMap<FontId, String>,
 }
 
+// todo!(linux): Double check this
 unsafe impl Send for LinuxTextSystemState {}
 unsafe impl Sync for LinuxTextSystemState {}
 
@@ -54,33 +55,52 @@ impl Default for LinuxTextSystem {
 
 #[allow(unused)]
 impl PlatformTextSystem for LinuxTextSystem {
+    // todo!(linux)
     fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<()> {
-        Ok(()) //TODO
+        Ok(())
     }
+
+    // todo!(linux)
     fn all_font_names(&self) -> Vec<String> {
         Vec::new()
     }
+
+    // todo!(linux)
     fn all_font_families(&self) -> Vec<String> {
         Vec::new()
     }
+
+    // todo!(linux)
     fn font_id(&self, descriptor: &Font) -> Result<FontId> {
-        Ok(FontId(0)) //TODO
+        Ok(FontId(0))
     }
+
+    // todo!(linux)
     fn font_metrics(&self, font_id: FontId) -> FontMetrics {
         unimplemented!()
     }
+
+    // todo!(linux)
     fn typographic_bounds(&self, font_id: FontId, glyph_id: GlyphId) -> Result<Bounds<f32>> {
         unimplemented!()
     }
+
+    // todo!(linux)
     fn advance(&self, font_id: FontId, glyph_id: GlyphId) -> Result<Size<f32>> {
         unimplemented!()
     }
+
+    // todo!(linux)
     fn glyph_for_char(&self, font_id: FontId, ch: char) -> Option<GlyphId> {
         None
     }
+
+    // todo!(linux)
     fn glyph_raster_bounds(&self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {
         unimplemented!()
     }
+
+    // todo!(linux)
     fn rasterize_glyph(
         &self,
         params: &RenderGlyphParams,
@@ -88,9 +108,13 @@ impl PlatformTextSystem for LinuxTextSystem {
     ) -> Result<(Size<DevicePixels>, Vec<u8>)> {
         unimplemented!()
     }
+
+    // todo!(linux)
     fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
         LineLayout::default() //TODO
     }
+
+    // todo!(linux)
     fn wrap_line(
         &self,
         text: &str,

crates/gpui/src/platform/linux/window.rs 🔗

@@ -77,6 +77,7 @@ pub(crate) struct LinuxWindowState {
 #[derive(Clone)]
 pub(crate) struct LinuxWindow(pub(crate) Arc<LinuxWindowState>);
 
+//todo!(linux): Remove other RawWindowHandle implementation
 unsafe impl blade_rwh::HasRawWindowHandle for RawWindow {
     fn raw_window_handle(&self) -> blade_rwh::RawWindowHandle {
         let mut wh = blade_rwh::XcbWindowHandle::empty();
@@ -287,10 +288,12 @@ impl PlatformWindow for LinuxWindow {
         self.0.inner.lock().scale_factor
     }
 
+    //todo!(linux)
     fn titlebar_height(&self) -> Pixels {
         unimplemented!()
     }
 
+    //todo!(linux)
     fn appearance(&self) -> WindowAppearance {
         unimplemented!()
     }
@@ -299,10 +302,12 @@ impl PlatformWindow for LinuxWindow {
         Rc::clone(&self.0.display)
     }
 
+    //todo!(linux)
     fn mouse_position(&self) -> Point<Pixels> {
         Point::default()
     }
 
+    //todo!(linux)
     fn modifiers(&self) -> crate::Modifiers {
         crate::Modifiers::default()
     }
@@ -311,12 +316,15 @@ impl PlatformWindow for LinuxWindow {
         self
     }
 
+    //todo!(linux)
     fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {}
 
+    //todo!(linux)
     fn take_input_handler(&mut self) -> Option<PlatformInputHandler> {
         None
     }
 
+    //todo!(linux)
     fn prompt(
         &self,
         _level: crate::PromptLevel,
@@ -327,24 +335,36 @@ impl PlatformWindow for LinuxWindow {
         unimplemented!()
     }
 
+    //todo!(linux)
     fn activate(&self) {}
 
+    //todo!(linux)
     fn set_title(&mut self, title: &str) {}
 
+    //todo!(linux)
     fn set_edited(&mut self, edited: bool) {}
 
+    //todo!(linux), this corresponds to `orderFrontCharacterPalette` on macOS,
+    // but it looks like the equivalent for Linux is GTK specific:
+    //
+    // https://docs.gtk.org/gtk3/signal.Entry.insert-emoji.html
+    //
+    // This API might need to change, or we might need to build an emoji picker into GPUI
     fn show_character_palette(&self) {
         unimplemented!()
     }
 
+    //todo!(linux)
     fn minimize(&self) {
         unimplemented!()
     }
 
+    //todo!(linux)
     fn zoom(&self) {
         unimplemented!()
     }
 
+    //todo!(linux)
     fn toggle_full_screen(&self) {
         unimplemented!()
     }
@@ -385,10 +405,12 @@ impl PlatformWindow for LinuxWindow {
         self.0.callbacks.lock().appearance_changed = Some(callback);
     }
 
+    //todo!(linux)
     fn is_topmost_for_position(&self, _position: crate::Point<Pixels>) -> bool {
         unimplemented!()
     }
 
+    //todo!(linux)
     fn invalidate(&self) {}
 
     fn draw(&self, scene: &crate::Scene) {

crates/gpui/src/platform/test/platform.rs 🔗

@@ -118,7 +118,11 @@ impl Platform for TestPlatform {
     }
 
     fn text_system(&self) -> Arc<dyn PlatformTextSystem> {
-        Arc::new(TestTextSystem {})
+        #[cfg(target_os = "linux")]
+        return Arc::new(TestTextSystem {});
+
+        #[cfg(target_os = "macos")]
+        return Arc::new(crate::platform::mac::MacTextSystem::new());
     }
 
     fn run(&self, _on_finish_launching: Box<dyn FnOnce()>) {

crates/gpui/src/platform/test/text_system.rs 🔗

@@ -7,6 +7,7 @@ use std::borrow::Cow;
 
 pub(crate) struct TestTextSystem {}
 
+//todo!(linux)
 #[allow(unused)]
 impl PlatformTextSystem for TestTextSystem {
     fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<()> {

crates/project/src/terminals.rs 🔗

@@ -7,8 +7,8 @@ use terminal::{
     Terminal, TerminalBuilder,
 };
 
-#[cfg(target_os = "macos")]
-use std::os::unix::ffi::OsStrExt;
+// #[cfg(target_os = "macos")]
+// use std::os::unix::ffi::OsStrExt;
 
 pub struct Terminals {
     pub(crate) local_handles: Vec<WeakModel<terminal::Terminal>>,

crates/zed/src/languages.rs 🔗

@@ -280,7 +280,8 @@ pub fn init(
         ],
     );
 
-    /// Produces a link error on linux due to duplicated `state_new` symbol
+    // Produces a link error on linux due to duplicated `state_new` symbol
+    // todo!(linux): Restore purescript
     #[cfg(not(target_os = "linux"))]
     language(
         "purescript",

crates/zed/src/main.rs 🔗

@@ -257,7 +257,7 @@ fn main() {
         initialize_workspace(app_state.clone(), cx);
 
         if stdout_is_a_pty() {
-            //TODO: unblock this
+            //todo!(linux): unblock this
             #[cfg(not(target_os = "linux"))]
             upload_panics_and_crashes(http.clone(), cx);
             cx.activate(true);
@@ -919,6 +919,7 @@ fn load_user_themes_in_background(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
     .detach();
 }
 
+//todo!(linux): Port fsevents to linux
 /// Spawns a background task to watch the themes directory for changes.
 #[cfg(target_os = "macos")]
 fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {