Fix / remove small todos

This commit is contained in:
Mikayla 2024-01-09 14:16:46 -08:00
parent 145f3f55e9
commit 80790d921d
No known key found for this signature in database
11 changed files with 52 additions and 34 deletions

View File

@ -262,7 +262,6 @@ async fn test_remove_channel_message(
#[track_caller]
fn assert_messages(chat: &Model<ChannelChat>, messages: &[&str], cx: &mut TestAppContext) {
// todo!(don't directly borrow here)
assert_eq!(
chat.read_with(cx, |chat, _| {
chat.messages()

View File

@ -41,12 +41,6 @@ pub fn init(cx: &mut AppContext) {
workspace.set_titlebar_item(titlebar_item.into(), cx)
})
.detach();
// todo!()
// cx.add_action(CollabTitlebarItem::share_project);
// cx.add_action(CollabTitlebarItem::unshare_project);
// cx.add_action(CollabTitlebarItem::toggle_user_menu);
// cx.add_action(CollabTitlebarItem::toggle_vcs_menu);
// cx.add_action(CollabTitlebarItem::toggle_project_menu);
}
pub struct CollabTitlebarItem {

View File

@ -19,7 +19,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
for window in notification_windows.drain(..) {
window
.update(&mut cx, |_, cx| {
// todo!()
cx.remove_window();
})
.log_err();

View File

@ -51,7 +51,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
for window in windows {
window
.update(cx, |_, cx| {
// todo!()
cx.remove_window();
})
.ok();
@ -64,7 +63,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
for window in windows {
window
.update(cx, |_, cx| {
// todo!()
cx.remove_window();
})
.ok();

View File

@ -1829,10 +1829,6 @@ impl Editor {
this.end_selection(cx);
this.scroll_manager.show_scrollbar(cx);
// todo!("use a different mechanism")
// let editor_created_event = EditorCreated(cx.handle());
// cx.emit_global(editor_created_event);
if mode == EditorMode::Full {
let should_auto_hide_scrollbars = cx.should_auto_hide_scrollbars();
cx.set_global(ScrollbarAutoHide(should_auto_hide_scrollbars));

View File

@ -539,7 +539,6 @@ fn test_clone(cx: &mut TestAppContext) {
);
}
//todo!(editor navigate)
#[gpui::test]
async fn test_navigation_history(cx: &mut TestAppContext) {
init_test(cx, |_| {});
@ -993,7 +992,6 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) {
});
}
//todo!(finish editor tests)
#[gpui::test]
fn test_move_cursor_different_line_lengths(cx: &mut TestAppContext) {
init_test(cx, |_| {});
@ -1259,7 +1257,6 @@ fn test_prev_next_word_boundary(cx: &mut TestAppContext) {
});
}
//todo!(finish editor tests)
#[gpui::test]
fn test_prev_next_word_bounds_with_soft_wrap(cx: &mut TestAppContext) {
init_test(cx, |_| {});
@ -1318,7 +1315,6 @@ fn test_prev_next_word_bounds_with_soft_wrap(cx: &mut TestAppContext) {
});
}
//todo!(simulate_resize)
#[gpui::test]
async fn test_move_start_of_paragraph_end_of_paragraph(cx: &mut gpui::TestAppContext) {
init_test(cx, |_| {});
@ -2546,7 +2542,6 @@ fn test_delete_line(cx: &mut TestAppContext) {
});
}
//todo!(select_anchor_ranges)
#[gpui::test]
fn test_join_lines_with_single_selection(cx: &mut TestAppContext) {
init_test(cx, |_| {});
@ -3114,7 +3109,6 @@ fn test_move_line_up_down_with_blocks(cx: &mut TestAppContext) {
});
}
//todo!(test_transpose)
#[gpui::test]
fn test_transpose(cx: &mut TestAppContext) {
init_test(cx, |_| {});
@ -4860,7 +4854,6 @@ async fn test_delete_autoclose_pair(cx: &mut gpui::TestAppContext) {
});
}
// todo!(select_anchor_ranges)
#[gpui::test]
async fn test_snippets(cx: &mut gpui::TestAppContext) {
init_test(cx, |_| {});
@ -6455,7 +6448,6 @@ fn test_highlighted_ranges(cx: &mut TestAppContext) {
});
}
// todo!(following)
#[gpui::test]
async fn test_following(cx: &mut gpui::TestAppContext) {
init_test(cx, |_| {});
@ -7094,7 +7086,6 @@ async fn test_move_to_enclosing_bracket(cx: &mut gpui::TestAppContext) {
);
}
// todo!(completions)
#[gpui::test(iterations = 10)]
async fn test_copilot(executor: BackgroundExecutor, cx: &mut gpui::TestAppContext) {
// flaky

View File

@ -95,7 +95,7 @@ pub fn up_by_rows(
text_layout_details: &TextLayoutDetails,
) -> (DisplayPoint, SelectionGoal) {
let mut goal_x = match goal {
SelectionGoal::HorizontalPosition(x) => x.into(), // todo!("Can the fields in SelectionGoal by Pixels? We should extract a geometry crate and depend on that.")
SelectionGoal::HorizontalPosition(x) => x.into(),
SelectionGoal::WrappedHorizontalPosition((_, x)) => x.into(),
SelectionGoal::HorizontalRange { end, .. } => end.into(),
_ => map.x_for_display_point(start, text_layout_details),

View File

@ -11,10 +11,9 @@ impl Editor {
return;
}
// todo!()
// if self.mouse_context_menu.read(cx).visible() {
// return None;
// }
if self.mouse_context_menu.is_some() {
return;
}
if matches!(self.mode, EditorMode::SingleLine) {
cx.propagate();

View File

@ -481,7 +481,7 @@ impl<V> View<V> {
use postage::prelude::{Sink as _, Stream as _};
let (tx, mut rx) = postage::mpsc::channel(1024);
let timeout_duration = Duration::from_millis(100); //todo!() cx.condition_duration();
let timeout_duration = Duration::from_millis(100);
let mut cx = cx.app.borrow_mut();
let subscriptions = (

View File

@ -15,8 +15,7 @@ pub struct Overlay {
anchor_corner: AnchorCorner,
fit_mode: OverlayFitMode,
anchor_position: Option<Point<Pixels>>,
// todo!();
// position_mode: OverlayPositionMode,
position_mode: OverlayPositionMode,
}
/// overlay gives you a floating element that will avoid overflowing the window bounds.
@ -27,6 +26,7 @@ pub fn overlay() -> Overlay {
anchor_corner: AnchorCorner::TopLeft,
fit_mode: OverlayFitMode::SwitchAnchor,
anchor_position: None,
position_mode: OverlayPositionMode::Window,
}
}
@ -44,6 +44,14 @@ impl Overlay {
self
}
/// Sets the position mode for this overlay. Local will have this
/// interpret it's [Overlay::position] as relative to the parent element.
/// While Window will have it interpret the position as relative to the window.
pub fn position_mode(mut self, mode: OverlayPositionMode) -> Self {
self.position_mode = mode;
self
}
/// Snap to window edge instead of switching anchor corner when an overflow would occur.
pub fn snap_to_window(mut self) -> Self {
self.fit_mode = OverlayFitMode::SnapToWindow;
@ -100,9 +108,14 @@ impl Element for Overlay {
child_max = child_max.max(&child_bounds.lower_right());
}
let size: Size<Pixels> = (child_max - child_min).into();
let origin = self.anchor_position.unwrap_or(bounds.origin);
let mut desired = self.anchor_corner.get_bounds(origin, size);
let (origin, mut desired) = self.position_mode.get_position_and_bounds(
self.anchor_position,
self.anchor_corner,
size,
bounds,
);
let limits = Bounds {
origin: Point::default(),
size: cx.viewport_size(),
@ -184,6 +197,35 @@ pub enum OverlayFitMode {
SwitchAnchor,
}
#[derive(Copy, Clone, PartialEq)]
pub enum OverlayPositionMode {
Window,
Local,
}
impl OverlayPositionMode {
fn get_position_and_bounds(
&self,
anchor_position: Option<Point<Pixels>>,
anchor_corner: AnchorCorner,
size: Size<Pixels>,
bounds: Bounds<Pixels>,
) -> (Point<Pixels>, Bounds<Pixels>) {
match self {
OverlayPositionMode::Window => {
let anchor_position = anchor_position.unwrap_or_else(|| bounds.origin);
let bounds = anchor_corner.get_bounds(anchor_position, size);
(anchor_position, bounds)
}
OverlayPositionMode::Local => {
let anchor_position = anchor_position.unwrap_or_default();
let bounds = anchor_corner.get_bounds(bounds.origin + anchor_position, size);
(anchor_position, bounds)
}
}
}
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum AnchorCorner {
TopLeft,

View File

@ -5,7 +5,7 @@ use std::ops::Range;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum SelectionGoal {
None,
HorizontalPosition(f32), // todo!("Can we use pixels here without adding a runtime gpui dependency?")
HorizontalPosition(f32),
HorizontalRange { start: f32, end: f32 },
WrappedHorizontalPosition((u32, f32)),
}