Remove remaining port related todos (#3994)

TODO:
- [x] Audit all TODO comments in Zed source and mark port related ones
with a !
- [x] Resolve all todos written as `todo!`

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2024-01-10 17:31:05 -08:00 committed by GitHub
commit 44969460cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 194 additions and 189 deletions

View file

@ -239,7 +239,8 @@ impl ActiveCall {
if result.is_ok() { if result.is_ok() {
this.update(&mut cx, |this, cx| this.report_call_event("invite", cx))?; this.update(&mut cx, |this, cx| this.report_call_event("invite", cx))?;
} else { } else {
// TODO: Resport collaboration error //TODO: report collaboration error
log::error!("invite failed: {:?}", result);
} }
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {

View file

@ -1,7 +1,9 @@
use crate::{rpc::RECONNECT_TIMEOUT, tests::TestServer}; use crate::{rpc::RECONNECT_TIMEOUT, tests::TestServer};
use channel::{ChannelChat, ChannelMessageId, MessageParams}; use channel::{ChannelChat, ChannelMessageId, MessageParams};
use collab_ui::chat_panel::ChatPanel;
use gpui::{BackgroundExecutor, Model, TestAppContext}; use gpui::{BackgroundExecutor, Model, TestAppContext};
use rpc::Notification; use rpc::Notification;
use workspace::dock::Panel;
#[gpui::test] #[gpui::test]
async fn test_basic_channel_messages( async fn test_basic_channel_messages(
@ -273,135 +275,135 @@ fn assert_messages(chat: &Model<ChannelChat>, messages: &[&str], cx: &mut TestAp
); );
} }
//todo!(collab_ui) #[gpui::test]
// #[gpui::test] async fn test_channel_message_changes(
// async fn test_channel_message_changes( executor: BackgroundExecutor,
// executor: BackgroundExecutor, cx_a: &mut TestAppContext,
// cx_a: &mut TestAppContext, cx_b: &mut TestAppContext,
// cx_b: &mut TestAppContext, ) {
// ) { let mut server = TestServer::start(executor.clone()).await;
// let mut server = TestServer::start(&executor).await; let client_a = server.create_client(cx_a, "user_a").await;
// let client_a = server.create_client(cx_a, "user_a").await; let client_b = server.create_client(cx_b, "user_b").await;
// let client_b = server.create_client(cx_b, "user_b").await;
// let channel_id = server let channel_id = server
// .make_channel( .make_channel(
// "the-channel", "the-channel",
// None, None,
// (&client_a, cx_a), (&client_a, cx_a),
// &mut [(&client_b, cx_b)], &mut [(&client_b, cx_b)],
// ) )
// .await; .await;
// // Client A sends a message, client B should see that there is a new message. // Client A sends a message, client B should see that there is a new message.
// let channel_chat_a = client_a let channel_chat_a = client_a
// .channel_store() .channel_store()
// .update(cx_a, |store, cx| store.open_channel_chat(channel_id, cx)) .update(cx_a, |store, cx| store.open_channel_chat(channel_id, cx))
// .await .await
// .unwrap(); .unwrap();
// channel_chat_a channel_chat_a
// .update(cx_a, |c, cx| c.send_message("one".into(), cx).unwrap()) .update(cx_a, |c, cx| c.send_message("one".into(), cx).unwrap())
// .await .await
// .unwrap(); .unwrap();
// executor.run_until_parked(); executor.run_until_parked();
// let b_has_messages = cx_b.read_with(|cx| { let b_has_messages = cx_b.update(|cx| {
// client_b client_b
// .channel_store() .channel_store()
// .read(cx) .read(cx)
// .has_new_messages(channel_id) .has_new_messages(channel_id)
// .unwrap() .unwrap()
// }); });
// assert!(b_has_messages); assert!(b_has_messages);
// // Opening the chat should clear the changed flag. // Opening the chat should clear the changed flag.
// cx_b.update(|cx| { cx_b.update(|cx| {
// collab_ui::init(&client_b.app_state, cx); collab_ui::init(&client_b.app_state, cx);
// }); });
// let project_b = client_b.build_empty_local_project(cx_b); let project_b = client_b.build_empty_local_project(cx_b);
// let workspace_b = client_b.build_workspace(&project_b, cx_b).root(cx_b); let (workspace_b, cx_b) = client_b.build_workspace(&project_b, cx_b);
// let chat_panel_b = workspace_b.update(cx_b, |workspace, cx| ChatPanel::new(workspace, cx));
// chat_panel_b
// .update(cx_b, |chat_panel, cx| {
// chat_panel.set_active(true, cx);
// chat_panel.select_channel(channel_id, None, cx)
// })
// .await
// .unwrap();
// executor.run_until_parked(); let chat_panel_b = workspace_b.update(cx_b, |workspace, cx| ChatPanel::new(workspace, cx));
chat_panel_b
.update(cx_b, |chat_panel, cx| {
chat_panel.set_active(true, cx);
chat_panel.select_channel(channel_id, None, cx)
})
.await
.unwrap();
// let b_has_messages = cx_b.read_with(|cx| { executor.run_until_parked();
// client_b
// .channel_store()
// .read(cx)
// .has_new_messages(channel_id)
// .unwrap()
// });
// assert!(!b_has_messages); let b_has_messages = cx_b.update(|cx| {
client_b
.channel_store()
.read(cx)
.has_new_messages(channel_id)
.unwrap()
});
// // Sending a message while the chat is open should not change the flag. assert!(!b_has_messages);
// channel_chat_a
// .update(cx_a, |c, cx| c.send_message("two".into(), cx).unwrap())
// .await
// .unwrap();
// executor.run_until_parked(); // Sending a message while the chat is open should not change the flag.
channel_chat_a
.update(cx_a, |c, cx| c.send_message("two".into(), cx).unwrap())
.await
.unwrap();
// let b_has_messages = cx_b.read_with(|cx| { executor.run_until_parked();
// client_b
// .channel_store()
// .read(cx)
// .has_new_messages(channel_id)
// .unwrap()
// });
// assert!(!b_has_messages); let b_has_messages = cx_b.update(|cx| {
client_b
.channel_store()
.read(cx)
.has_new_messages(channel_id)
.unwrap()
});
// // Sending a message while the chat is closed should change the flag. assert!(!b_has_messages);
// chat_panel_b.update(cx_b, |chat_panel, cx| {
// chat_panel.set_active(false, cx);
// });
// // Sending a message while the chat is open should not change the flag. // Sending a message while the chat is closed should change the flag.
// channel_chat_a chat_panel_b.update(cx_b, |chat_panel, cx| {
// .update(cx_a, |c, cx| c.send_message("three".into(), cx).unwrap()) chat_panel.set_active(false, cx);
// .await });
// .unwrap();
// executor.run_until_parked(); // Sending a message while the chat is open should not change the flag.
channel_chat_a
.update(cx_a, |c, cx| c.send_message("three".into(), cx).unwrap())
.await
.unwrap();
// let b_has_messages = cx_b.read_with(|cx| { executor.run_until_parked();
// client_b
// .channel_store()
// .read(cx)
// .has_new_messages(channel_id)
// .unwrap()
// });
// assert!(b_has_messages); let b_has_messages = cx_b.update(|cx| {
client_b
.channel_store()
.read(cx)
.has_new_messages(channel_id)
.unwrap()
});
// // Closing the chat should re-enable change tracking assert!(b_has_messages);
// cx_b.update(|_| drop(chat_panel_b));
// channel_chat_a // Closing the chat should re-enable change tracking
// .update(cx_a, |c, cx| c.send_message("four".into(), cx).unwrap()) cx_b.update(|_| drop(chat_panel_b));
// .await
// .unwrap();
// executor.run_until_parked(); channel_chat_a
.update(cx_a, |c, cx| c.send_message("four".into(), cx).unwrap())
.await
.unwrap();
// let b_has_messages = cx_b.read_with(|cx| { executor.run_until_parked();
// client_b
// .channel_store()
// .read(cx)
// .has_new_messages(channel_id)
// .unwrap()
// });
// assert!(b_has_messages); let b_has_messages = cx_b.update(|cx| {
// } client_b
.channel_store()
.read(cx)
.has_new_messages(channel_id)
.unwrap()
});
assert!(b_has_messages);
}

View file

@ -111,7 +111,6 @@ fn notification_window_options(
let screen_bounds = screen.bounds(); let screen_bounds = screen.bounds();
let size: Size<GlobalPixels> = window_size.into(); let size: Size<GlobalPixels> = window_size.into();
// todo!() use content bounds instead of screen.bounds and get rid of magics in point's 2nd argument.
let bounds = gpui::Bounds::<GlobalPixels> { let bounds = gpui::Bounds::<GlobalPixels> {
origin: screen_bounds.upper_right() origin: screen_bounds.upper_right()
- point( - point(

View file

@ -1043,7 +1043,7 @@ mod tests {
#[gpui::test(iterations = 100)] #[gpui::test(iterations = 100)]
async fn test_random_wraps(cx: &mut gpui::TestAppContext, mut rng: StdRng) { async fn test_random_wraps(cx: &mut gpui::TestAppContext, mut rng: StdRng) {
// todo!() this test is flaky // todo this test is flaky
init_test(cx); init_test(cx);
cx.background_executor.set_block_on_ticks(0..=50); cx.background_executor.set_block_on_ticks(0..=50);

View file

@ -1017,7 +1017,6 @@ impl EditorElement {
.chars_at(cursor_position) .chars_at(cursor_position)
.next() .next()
.and_then(|(character, _)| { .and_then(|(character, _)| {
// todo!() currently shape_line panics if text conatins newlines
let text = if character == '\n' { let text = if character == '\n' {
SharedString::from(" ") SharedString::from(" ")
} else { } else {

View file

@ -312,7 +312,7 @@ impl FileFinderDelegate {
cx: &mut ViewContext<FileFinder>, cx: &mut ViewContext<FileFinder>,
) -> Self { ) -> Self {
cx.observe(&project, |file_finder, _, cx| { cx.observe(&project, |file_finder, _, cx| {
//todo!() We should probably not re-render on every project anything //todo We should probably not re-render on every project anything
file_finder file_finder
.picker .picker
.update(cx, |picker, cx| picker.refresh(cx)) .update(cx, |picker, cx| picker.refresh(cx))

View file

@ -269,6 +269,7 @@ unsafe fn build_window_class(name: &'static str, superclass: &Class) -> *const C
sel!(windowShouldClose:), sel!(windowShouldClose:),
window_should_close as extern "C" fn(&Object, Sel, id) -> BOOL, window_should_close as extern "C" fn(&Object, Sel, id) -> BOOL,
); );
decl.add_method(sel!(close), close_window as extern "C" fn(&Object, Sel)); decl.add_method(sel!(close), close_window as extern "C" fn(&Object, Sel));
decl.add_method( decl.add_method(
@ -685,9 +686,6 @@ impl Drop for MacWindow {
this.executor this.executor
.spawn(async move { .spawn(async move {
unsafe { unsafe {
// todo!() this panic()s when you click the red close button
// unless should_close returns false.
// (luckliy in zed it always returns false)
window.close(); window.close();
} }
}) })
@ -1116,7 +1114,7 @@ extern "C" fn handle_key_event(this: &Object, native_event: id, key_equivalent:
// we don't match cmd/fn because they don't seem to use IME // we don't match cmd/fn because they don't seem to use IME
modifiers: Default::default(), modifiers: Default::default(),
key: ime_text.clone().unwrap(), key: ime_text.clone().unwrap(),
ime_key: None, // todo!("handle IME key") ime_key: None,
}, },
}; };
handled = callback(InputEvent::KeyDown(event_with_ime_text)); handled = callback(InputEvent::KeyDown(event_with_ime_text));
@ -1570,6 +1568,9 @@ extern "C" fn insert_text(this: &Object, _: Sel, text: id, replacement_range: NS
replacement_range, replacement_range,
text: text.to_string(), text: text.to_string(),
}); });
if text.to_string().to_ascii_lowercase() != pending_key_down.0.keystroke.key {
pending_key_down.0.keystroke.ime_key = Some(text.to_string());
}
window_state.lock().pending_key_down = Some(pending_key_down); window_state.lock().pending_key_down = Some(pending_key_down);
} }
} }

View file

@ -137,7 +137,7 @@ impl Boundary {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{font, TestAppContext, TestDispatcher}; use crate::{font, TestAppContext, TestDispatcher, TextRun, WrapBoundary};
use rand::prelude::*; use rand::prelude::*;
#[test] #[test]
@ -206,75 +206,70 @@ mod tests {
}); });
} }
// todo!("move this to a test on TextSystem::layout_text") // For compatibility with the test macro
// todo! repeat this test use crate as gpui;
// #[test]
// fn test_wrap_shaped_line() {
// App::test().run(|cx| {
// let text_system = cx.text_system().clone();
// let normal = TextRun { #[crate::test]
// len: 0, fn test_wrap_shaped_line(cx: &mut TestAppContext) {
// font: font("Helvetica"), cx.update(|cx| {
// color: Default::default(), let text_system = cx.text_system().clone();
// underline: Default::default(),
// };
// let bold = TextRun {
// len: 0,
// font: font("Helvetica").bold(),
// color: Default::default(),
// underline: Default::default(),
// };
// impl TextRun { let normal = TextRun {
// fn with_len(&self, len: usize) -> Self { len: 0,
// let mut this = self.clone(); font: font("Helvetica"),
// this.len = len; color: Default::default(),
// this underline: Default::default(),
// } background_color: None,
// } };
let bold = TextRun {
len: 0,
font: font("Helvetica").bold(),
color: Default::default(),
underline: Default::default(),
background_color: None,
};
// let text = "aa bbb cccc ddddd eeee".into(); impl TextRun {
// let lines = text_system fn with_len(&self, len: usize) -> Self {
// .layout_text( let mut this = self.clone();
// &text, this.len = len;
// px(16.), this
// &[ }
// normal.with_len(4), }
// bold.with_len(5),
// normal.with_len(6), let text = "aa bbb cccc ddddd eeee".into();
// bold.with_len(1), let lines = text_system
// normal.with_len(7), .shape_text(
// ], text,
// None, px(16.),
// ) &[
// .unwrap(); normal.with_len(4),
// let line = &lines[0]; bold.with_len(5),
normal.with_len(6),
// let mut wrapper = LineWrapper::new( bold.with_len(1),
// text_system.font_id(&normal.font).unwrap(), normal.with_len(7),
// px(16.), ],
// text_system.platform_text_system.clone(), Some(px(72.)),
// ); )
// assert_eq!( .unwrap();
// wrapper
// .wrap_shaped_line(&text, &line, px(72.)) assert_eq!(
// .collect::<Vec<_>>(), lines[0].layout.wrap_boundaries(),
// &[ &[
// ShapedBoundary { WrapBoundary {
// run_ix: 1, run_ix: 1,
// glyph_ix: 3 glyph_ix: 3
// }, },
// ShapedBoundary { WrapBoundary {
// run_ix: 2, run_ix: 2,
// glyph_ix: 3 glyph_ix: 3
// }, },
// ShapedBoundary { WrapBoundary {
// run_ix: 4, run_ix: 4,
// glyph_ix: 2 glyph_ix: 2
// } }
// ], ],
// ); );
// }); });
// } }
} }

View file

@ -1904,7 +1904,16 @@ impl<'a> WindowContext<'a> {
let mut this = self.to_async(); let mut this = self.to_async();
self.window self.window
.platform_window .platform_window
.on_should_close(Box::new(move || this.update(|_, cx| f(cx)).unwrap_or(true))) .on_should_close(Box::new(move || {
this.update(|_, cx| {
// Ensure that the window is removed from the app if it's been closed.
if f(cx) {
cx.remove_window();
}
false
})
.unwrap_or(true)
}))
} }
} }

View file

@ -1130,7 +1130,6 @@ mod tests {
#[gpui::test] #[gpui::test]
async fn test_search_simple(cx: &mut TestAppContext) { async fn test_search_simple(cx: &mut TestAppContext) {
let (editor, search_bar, cx) = init_test(cx); let (editor, search_bar, cx) = init_test(cx);
// todo! osiewicz: these tests asserted on background color as well, that should be brought back.
let display_points_of = |background_highlights: Vec<(Range<DisplayPoint>, Hsla)>| { let display_points_of = |background_highlights: Vec<(Range<DisplayPoint>, Hsla)>| {
background_highlights background_highlights
.into_iter() .into_iter()
@ -1395,7 +1394,6 @@ mod tests {
}) })
.await .await
.unwrap(); .unwrap();
// todo! osiewicz: these tests previously asserted on background color highlights; that should be introduced back.
let display_points_of = |background_highlights: Vec<(Range<DisplayPoint>, Hsla)>| { let display_points_of = |background_highlights: Vec<(Range<DisplayPoint>, Hsla)>| {
background_highlights background_highlights
.into_iter() .into_iter()

View file

@ -22,7 +22,7 @@ pub struct PlayerColors(pub Vec<PlayerColor>);
impl Default for PlayerColors { impl Default for PlayerColors {
/// Don't use this! /// Don't use this!
/// We have to have a default to be `[refineable::Refinable]`. /// We have to have a default to be `[refineable::Refinable]`.
/// todo!("Find a way to not need this for Refinable") /// TODO "Find a way to not need this for Refinable"
fn default() -> Self { fn default() -> Self {
Self::dark() Self::dark()
} }

View file

@ -148,6 +148,7 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
cx.on_window_should_close(move |cx| { cx.on_window_should_close(move |cx| {
handle handle
.update(cx, |workspace, cx| { .update(cx, |workspace, cx| {
// We'll handle closing asynchoronously
workspace.close_window(&Default::default(), cx); workspace.close_window(&Default::default(), cx);
false false
}) })