Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @naaiyy
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always

jobs:
check_style:
name: Check style
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Check formatting
run: cargo fmt --all --check

clippy:
name: Clippy
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Run clippy
run: cargo clippy --workspace --all-targets -- -D warnings

tests:
name: Tests
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: cargo test --workspace --no-fail-fast

ci_pass:
name: CI Pass
runs-on: ubuntu-latest
needs: [check_style, clippy, tests]
if: always()
steps:
- name: Check results
run: |
if [[ "${{ needs.check_style.result }}" == "failure" || "${{ needs.clippy.result }}" == "failure" || "${{ needs.tests.result }}" == "failure" ]]; then
echo "One or more checks failed"
exit 1
fi
echo "All checks passed"
20 changes: 10 additions & 10 deletions crates/gpui/examples/native_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ impl Render for NativeButtonExample {
.text_color(fg)
.child(format!("Count: {}", self.count))
.child(
native_button("increment", "Increment")
.on_click(cx.listener(|this, _event, _window, cx| {
native_button("increment", "Increment").on_click(cx.listener(
|this, _event, _window, cx| {
this.count += 1;
cx.notify();
})),
)
.child(
native_button("reset", "Reset")
.on_click(cx.listener(|this, _event, _window, cx| {
this.count = 0;
cx.notify();
})),
},
)),
)
.child(native_button("reset", "Reset").on_click(cx.listener(
|this, _event, _window, cx| {
this.count = 0;
cx.notify();
},
)))
}
}

Expand Down
53 changes: 27 additions & 26 deletions crates/gpui/examples/native_text_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ impl Render for TextFieldExample {
.gap_4()
.bg(bg)
.text_color(fg)
.child(
div()
.text_xl()
.child("Native Text Field Demo"),
)
.child(div().text_xl().child("Native Text Field Demo"))
// Basic text field
.child(
div()
Expand All @@ -45,10 +41,12 @@ impl Render for TextFieldExample {
.child(
native_text_field("basic")
.placeholder("Type something...")
.on_change(cx.listener(|this, event: &gpui::TextChangeEvent, _window, cx| {
this.basic_text = event.text.clone();
cx.notify();
})),
.on_change(cx.listener(
|this, event: &gpui::TextChangeEvent, _window, cx| {
this.basic_text = event.text.clone();
cx.notify();
},
)),
)
.child(
div()
Expand All @@ -68,10 +66,12 @@ impl Render for TextFieldExample {
native_text_field("password")
.placeholder("Enter password...")
.secure(true)
.on_change(cx.listener(|this, event: &gpui::TextChangeEvent, _window, cx| {
this.password_text = event.text.clone();
cx.notify();
})),
.on_change(cx.listener(
|this, event: &gpui::TextChangeEvent, _window, cx| {
this.password_text = event.text.clone();
cx.notify();
},
)),
)
.child(
div()
Expand All @@ -91,10 +91,12 @@ impl Render for TextFieldExample {
native_text_field("search")
.placeholder("Search (press Enter)...")
.field_style(NativeTextFieldStyle::Rounded)
.on_submit(cx.listener(|this, event: &gpui::TextSubmitEvent, _window, cx| {
this.submitted_text = event.text.clone();
cx.notify();
})),
.on_submit(cx.listener(
|this, event: &gpui::TextSubmitEvent, _window, cx| {
this.submitted_text = event.text.clone();
cx.notify();
},
)),
)
.child(
div()
Expand All @@ -110,15 +112,14 @@ impl Render for TextFieldExample {
.disabled(true),
)
// Clear button
.child(
native_button("clear", "Clear All")
.on_click(cx.listener(|this, _event, _window, cx| {
this.basic_text.clear();
this.password_text.clear();
this.submitted_text.clear();
cx.notify();
})),
)
.child(native_button("clear", "Clear All").on_click(cx.listener(
|this, _event, _window, cx| {
this.basic_text.clear();
this.password_text.clear();
this.submitted_text.clear();
cx.notify();
},
)))
}
}

Expand Down
70 changes: 28 additions & 42 deletions crates/gpui/examples/native_toggle_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,57 +48,43 @@ impl Render for ToggleGroupExample {
.text_color(fg)
.child(format!(
"View: {} | Sort: {}",
Self::VIEW_MODES[self.view_mode], Self::SORT_ORDERS[self.sort_order]
Self::VIEW_MODES[self.view_mode],
Self::SORT_ORDERS[self.sort_order]
))
// View mode selector
.child(
div()
.flex()
.gap_3()
.items_center()
.child("View:")
.child(
native_toggle_group("view_mode", &Self::VIEW_MODES)
.selected_index(self.view_mode)
.segment_style(segmented_style)
.on_select(cx.listener(|this, event: &SegmentSelectEvent, _, cx| {
this.view_mode = event.index;
cx.notify();
})),
),
div().flex().gap_3().items_center().child("View:").child(
native_toggle_group("view_mode", &Self::VIEW_MODES)
.selected_index(self.view_mode)
.segment_style(segmented_style)
.on_select(cx.listener(|this, event: &SegmentSelectEvent, _, cx| {
this.view_mode = event.index;
cx.notify();
})),
),
)
// Sort order selector
.child(
div()
.flex()
.gap_3()
.items_center()
.child("Sort:")
.child(
native_toggle_group("sort_order", &Self::SORT_ORDERS)
.selected_index(self.sort_order)
.segment_style(segmented_style)
.on_select(cx.listener(|this, event: &SegmentSelectEvent, _, cx| {
this.sort_order = event.index;
cx.notify();
})),
),
div().flex().gap_3().items_center().child("Sort:").child(
native_toggle_group("sort_order", &Self::SORT_ORDERS)
.selected_index(self.sort_order)
.segment_style(segmented_style)
.on_select(cx.listener(|this, event: &SegmentSelectEvent, _, cx| {
this.sort_order = event.index;
cx.notify();
})),
),
)
// Style selector (segmented control to change the style of the other controls)
.child(
div()
.flex()
.gap_3()
.items_center()
.child("Style:")
.child(
native_toggle_group("style_selector", &Self::STYLE_NAMES)
.selected_index(self.style_index)
.on_select(cx.listener(|this, event: &SegmentSelectEvent, _, cx| {
this.style_index = event.index;
cx.notify();
})),
),
div().flex().gap_3().items_center().child("Style:").child(
native_toggle_group("style_selector", &Self::STYLE_NAMES)
.selected_index(self.style_index)
.on_select(cx.listener(|this, event: &SegmentSelectEvent, _, cx| {
this.style_index = event.index;
cx.notify();
})),
),
)
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/gpui/src/elements/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ impl StateInner {

if self.scroll_handler.is_some() {
let visible_range = self.visible_range(height, scroll_top);
#[allow(clippy::unnecessary_unwrap)]
self.scroll_handler.as_mut().unwrap()(
&ListScrollEvent {
visible_range,
Expand Down
1 change: 1 addition & 0 deletions crates/gpui/src/elements/native_toggle_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl NativeToggleGroup {
// Persisted element state
// =============================================================================

#[allow(dead_code)]
struct NativeToggleGroupState {
control_ptr: *mut c_void,
target_ptr: *mut c_void,
Expand Down
4 changes: 2 additions & 2 deletions crates/gpui/src/key_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ impl DispatchTree {
if let Some(context) = node.context.clone() {
self.context_stack.push(context);
}
if node.view_id.is_some() {
self.view_stack.push(node.view_id.unwrap());
if let Some(view_id) = node.view_id {
self.view_stack.push(view_id);
}
self.node_stack.push(node_id);
current_node_id = node.parent;
Expand Down
4 changes: 2 additions & 2 deletions crates/gpui/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ pub use keystroke::*;
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub(crate) use linux::*;
#[cfg(target_os = "macos")]
pub(crate) use mac::*;
#[cfg(target_os = "macos")]
pub(crate) use mac::native_controls;
#[cfg(target_os = "macos")]
pub(crate) use mac::*;
#[cfg(any(test, feature = "test-support"))]
pub(crate) use test::*;
#[cfg(target_os = "windows")]
Expand Down
1 change: 1 addition & 0 deletions crates/gpui/src/platform/mac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod open_type;
#[cfg(feature = "font-kit")]
mod text_system;

#[allow(dead_code)]
pub(crate) mod native_controls;
mod platform;
mod window;
Expand Down
4 changes: 0 additions & 4 deletions crates/sum_tree/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ where
}

#[track_caller]

pub fn prev(&mut self) {
self.search_backward(|_| true)
}
Expand Down Expand Up @@ -395,7 +394,6 @@ where
{
/// Returns whether we found the item you were seeking for.
#[track_caller]

pub fn seek<Target>(&mut self, pos: &Target, bias: Bias) -> bool
where
Target: SeekTarget<'a, T::Summary, D>,
Expand All @@ -410,7 +408,6 @@ where
///
/// If we did not seek before, use seek instead in that case.
#[track_caller]

pub fn seek_forward<Target>(&mut self, pos: &Target, bias: Bias) -> bool
where
Target: SeekTarget<'a, T::Summary, D>,
Expand Down Expand Up @@ -452,7 +449,6 @@ where

/// Returns whether we found the item you were seeking for.
#[track_caller]

fn seek_internal(
&mut self,
target: &dyn SeekTarget<'a, T::Summary, D>,
Expand Down
3 changes: 0 additions & 3 deletions crates/sum_tree/src/sum_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ impl<T: Item> SumTree<T> {
/// A more efficient version of `Cursor::new()` + `Cursor::seek()` + `Cursor::item()`.
///
/// Only returns the item that exactly has the target match.

pub fn find_exact<'a, 'slf, D, Target>(
&'slf self,
cx: <T::Summary as Summary>::Context<'a>,
Expand All @@ -407,7 +406,6 @@ impl<T: Item> SumTree<T> {
}

/// A more efficient version of `Cursor::new()` + `Cursor::seek()` + `Cursor::item()`

pub fn find<'a, 'slf, D, Target>(
&'slf self,
cx: <T::Summary as Summary>::Context<'a>,
Expand Down Expand Up @@ -492,7 +490,6 @@ impl<T: Item> SumTree<T> {
}

/// A more efficient version of `Cursor::new()` + `Cursor::seek()` + `Cursor::item()`

pub fn find_with_prev<'a, 'slf, D, Target>(
&'slf self,
cx: <T::Summary as Summary>::Context<'a>,
Expand Down