ely-mark: rustfmt the files R3.1 left unformatted

Formatting alone; cargo fmt --check failed on these six.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-14 09:12:48 -04:00
1 parent 256240c365
commit d07f0ddb7c
6 files changed
+168 -56

No files matched your search

+20 -7
View File
@@ -196,8 +196,8 @@ impl Desk {
mod tests { mod tests {
use ely_gpui_component::documents::DocumentLook; use ely_gpui_component::documents::DocumentLook;
use gpui::{ use gpui::{
Entity, Modifiers, ScrollDelta, ScrollWheelEvent, TestAppContext, VisualTestContext, Entity, Modifiers, ScrollDelta, ScrollWheelEvent, TestAppContext, VisualTestContext, point,
point, rems, rems,
}; };
use crate::desk::{ use crate::desk::{
@@ -286,8 +286,11 @@ mod tests {
tempfile::tempdir().expect("files"), tempfile::tempdir().expect("files"),
); );
let path = files.path().join("a.md"); let path = files.path().join("a.md");
std::fs::write(&path, "a std::fs::write(
").expect("a file"); &path, "a
",
)
.expect("a file");
let (desk, cx) = start(cx, data.path()); let (desk, cx) = start(cx, data.path());
open(&desk, &path, cx); open(&desk, &path, cx);
let focus = desk.read_with(cx, |desk, _| desk.core.focus.clone()); let focus = desk.read_with(cx, |desk, _| desk.core.focus.clone());
@@ -300,12 +303,22 @@ mod tests {
..Default::default() ..Default::default()
}; };
let other = match cfg!(target_os = "macos") { let other = match cfg!(target_os = "macos") {
true => Modifiers { control: true, ..Default::default() }, true => Modifiers {
false => Modifiers { platform: true, ..Default::default() }, control: true,
..Default::default()
},
false => Modifiers {
platform: true,
..Default::default()
},
}; };
cx.simulate_event(wheel(other, 3.0)); cx.simulate_event(wheel(other, 3.0));
cx.run_until_parked(); cx.run_until_parked();
assert_eq!(document_look(&desk, cx).scale, 1.0, "only Ctrl, or Cmd on macOS"); assert_eq!(
document_look(&desk, cx).scale,
1.0,
"only Ctrl, or Cmd on macOS"
);
cx.simulate_event(wheel(Modifiers::secondary_key(), 3.0)); cx.simulate_event(wheel(Modifiers::secondary_key(), 3.0));
cx.run_until_parked(); cx.run_until_parked();
assert_eq!(document_look(&desk, cx).scale, 1.1, "a notch is one step"); assert_eq!(document_look(&desk, cx).scale, 1.1, "a notch is one step");
+11 -2
View File
@@ -293,7 +293,13 @@ impl Desk {
} }
/// A new file with the saved text; edits stay. /// A new file with the saved text; edits stay.
fn keep_edits(&mut self, id: u64, disk: Source, fingerprint: Fingerprint, cx: &mut Context<Self>) { fn keep_edits(
&mut self,
id: u64,
disk: Source,
fingerprint: Fingerprint,
cx: &mut Context<Self>,
) {
let Some(tab) = self.tab_mut(id) else { let Some(tab) = self.tab_mut(id) else {
return; return;
}; };
@@ -398,7 +404,10 @@ fn watch(dirs: &[PathBuf], cx: &mut Context<Desk>) -> notify::Result<Recommended
let (sender, mut changes) = mpsc::unbounded(); let (sender, mut changes) = mpsc::unbounded();
let mut watcher = notify::recommended_watcher(move |event: notify::Result<notify::Event>| { let mut watcher = notify::recommended_watcher(move |event: notify::Result<notify::Event>| {
// Reads, ours included, are no change. // Reads, ours included, are no change.
if event.as_ref().is_ok_and(|event| ely_ui::watching::only_read(&event.kind)) { if event
.as_ref()
.is_ok_and(|event| ely_ui::watching::only_read(&event.kind))
{
return; return;
} }
let _ = sender.unbounded_send(event.map(|_| ()).map_err(|error| error.to_string())); let _ = sender.unbounded_send(event.map(|_| ()).map_err(|error| error.to_string()));
+23 -10
View File
@@ -141,8 +141,11 @@ impl Keeping {
/// The untitled tabs to make: their place here and name. /// The untitled tabs to make: their place here and name.
pub fn untitled(&self) -> Vec<(usize, String)> { pub fn untitled(&self) -> Vec<(usize, String)> {
let waiting = self.waiting.iter().enumerate(); let waiting = self.waiting.iter().enumerate();
let untitled = waiting.filter(|(_, waiting)| waiting.kept.path.is_none() && waiting.tab.is_none()); let untitled =
untitled.map(|(at, waiting)| (at, waiting.kept.name.clone())).collect() waiting.filter(|(_, waiting)| waiting.kept.path.is_none() && waiting.tab.is_none());
untitled
.map(|(at, waiting)| (at, waiting.kept.name.clone()))
.collect()
} }
/// Entry `at` belongs to untitled tab `tab`. /// Entry `at` belongs to untitled tab `tab`.
@@ -152,11 +155,14 @@ impl Keeping {
/// What tab `id` takes: its file or its copy. /// What tab `id` takes: its file or its copy.
fn take(&mut self, real: Option<&PathBuf>, id: u64) -> Option<Waiting> { fn take(&mut self, real: Option<&PathBuf>, id: u64) -> Option<Waiting> {
let at = self.waiting.iter().position(|waiting| match (&waiting.real, real) { let at = self
(Some(kept), Some(open)) => kept == open, .waiting
(None, None) => waiting.tab == Some(id), .iter()
_ => false, .position(|waiting| match (&waiting.real, real) {
})?; (Some(kept), Some(open)) => kept == open,
(None, None) => waiting.tab == Some(id),
_ => false,
})?;
Some(self.waiting.remove(at)) Some(self.waiting.remove(at))
} }
@@ -243,7 +249,9 @@ impl Desk {
// Modes take focus: in the window, after this update. // Modes take focus: in the window, after this update.
cx.spawn(async move |desk, cx| { cx.spawn(async move |desk, cx| {
let shown = ely_office::in_window(&desk, cx, |_, window, cx| { let shown = ely_office::in_window(&desk, cx, |_, window, cx| {
view.update(cx, |view, cx| view.reopen(mode, kept.place, back, window, cx)) view.update(cx, |view, cx| {
view.reopen(mode, kept.place, back, window, cx)
})
}); });
if let Err(error) = shown { if let Err(error) = shown {
log::warn!("mark: tab {id} did not restore: {error:#}"); log::warn!("mark: tab {id} did not restore: {error:#}");
@@ -285,7 +293,8 @@ impl Desk {
.spawn(async move { .spawn(async move {
let now = SystemTime::now(); let now = SystemTime::now();
let limits = ely_platform::storage::limits(ely_platform::AppId::Mark)?; let limits = ely_platform::storage::limits(ely_platform::AppId::Mark)?;
let mut recovery = Recovery::new(folder).with_limits(limits.keep, limits.megabytes * 1024 * 1024); let mut recovery = Recovery::new(folder)
.with_limits(limits.keep, limits.megabytes * 1024 * 1024);
recovery.write_once(current.as_bytes(), None, now) recovery.write_once(current.as_bytes(), None, now)
}) })
.await; .await;
@@ -350,7 +359,11 @@ impl Desk {
None => text(cx, "office.stopped.never", &[]).to_string(), None => text(cx, "office.stopped.never", &[]).to_string(),
}; };
let name = tab.name.to_string(); let name = tab.name.to_string();
let said = text(cx, "mark.recovery.failed", &[("name", &name), ("error", &error), ("at", &at)]); let said = text(
cx,
"mark.recovery.failed",
&[("name", &name), ("error", &error), ("at", &at)],
);
self.toast_unlogged(said, ely_gpui_component::primitives::Severity::Danger, cx); self.toast_unlogged(said, ely_gpui_component::primitives::Severity::Danger, cx);
} }
+38 -15
View File
@@ -15,8 +15,7 @@ use ely_office::prelude::*;
use ely_ui::{commands, i18n::text}; use ely_ui::{commands, i18n::text};
use gpui::{ use gpui::{
AnyElement, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement, AnyElement, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
ParentElement as _, Render, ParentElement as _, Render, SharedString, Styled as _, WeakEntity, Window, div,
SharedString, Styled as _, WeakEntity, Window, div,
}; };
use crate::desk::Desk; use crate::desk::Desk;
@@ -251,17 +250,21 @@ impl Side {
}, },
); );
let outline = outline.on_select(move |key, window, cx| { let outline = outline.on_select(move |key, window, cx| {
let Some(heading) = key.parse::<usize>().ok().and_then(|at| headings.get(at)) else { let Some(heading) = key.parse::<usize>().ok().and_then(|at| headings.get(at)) else {
return log::error!("mark: the outline chose no heading"); return log::error!("mark: the outline chose no heading");
}; };
// The heading in view, the caret on it. // The heading in view, the caret on it.
let line = heading.line; let line = heading.line;
view.update(cx, |view, cx| view.reveal((line, 0), window, cx)); view.update(cx, |view, cx| view.reveal((line, 0), window, cx));
}); });
ScrollArea::new("mark-outline-scroll") ScrollArea::new("mark-outline-scroll")
.vertical() .vertical()
.size_full() .size_full()
.child(div().debug_selector(|| "mark-outline".into()).child(outline)) .child(
div()
.debug_selector(|| "mark-outline".into())
.child(outline),
)
.into_any_element() .into_any_element()
} }
@@ -269,9 +272,17 @@ impl Side {
let this = cx.entity(); let this = cx.entity();
let scope = SegmentedControl::new("mark-scope", if self.wide { "folder" } else { "file" }) let scope = SegmentedControl::new("mark-scope", if self.wide { "folder" } else { "file" })
.size(ControlSize::Sm) .size(ControlSize::Sm)
.segment("file", text(cx, "mark.search.file", &[]), Some(IconName::File)); .segment(
"file",
text(cx, "mark.search.file", &[]),
Some(IconName::File),
);
let scope = match desk.read(cx).folder { let scope = match desk.read(cx).folder {
Some(_) => scope.segment("folder", text(cx, "mark.search.folder", &[]), Some(IconName::Folder)), Some(_) => scope.segment(
"folder",
text(cx, "mark.search.folder", &[]),
Some(IconName::Folder),
),
None => scope, None => scope,
}; };
let scope = scope.on_change(move |key, _, cx| { let scope = scope.on_change(move |key, _, cx| {
@@ -350,9 +361,21 @@ impl Render for Side {
}; };
let panes = SegmentedControl::new("mark-pane", key) let panes = SegmentedControl::new("mark-pane", key)
.size(ControlSize::Sm) .size(ControlSize::Sm)
.segment("files", text(cx, "mark.pane.files", &[]), Some(IconName::Folder)) .segment(
.segment("outline", text(cx, "mark.pane.outline", &[]), Some(IconName::List)) "files",
.segment("search", text(cx, "mark.pane.search", &[]), Some(IconName::Search)) text(cx, "mark.pane.files", &[]),
Some(IconName::Folder),
)
.segment(
"outline",
text(cx, "mark.pane.outline", &[]),
Some(IconName::List),
)
.segment(
"search",
text(cx, "mark.pane.search", &[]),
Some(IconName::Search),
)
.on_change(move |key, _, cx| { .on_change(move |key, _, cx| {
this.update(cx, |side, cx| { this.update(cx, |side, cx| {
side.pane = match key.as_ref() { side.pane = match key.as_ref() {
+69 -20
View File
@@ -1,9 +1,6 @@
//! Whether Git sees the file changed; ElyTree does the rest. //! Whether Git sees the file changed; ElyTree does the rest.
use std::{ use std::{io, path::Path};
io,
path::Path,
};
use ely_gpui_component::{primitives::Severity, shell::StatusBarItem}; use ely_gpui_component::{primitives::Severity, shell::StatusBarItem};
use ely_office::prelude::*; use ely_office::prelude::*;
@@ -145,7 +142,10 @@ impl Desk {
} }
let (this, file) = (this.clone(), file.clone()); let (this, file) = (this.clone(), file.clone());
cx.spawn(async move |cx| { cx.spawn(async move |cx| {
let opened = cx.background_executor().spawn(async move { ely_platform::apps::open(AppId::Tree, &[file]) }).await; let opened = cx
.background_executor()
.spawn(async move { ely_platform::apps::open(AppId::Tree, &[file]) })
.await;
if let Err(error) = opened { if let Err(error) = opened {
log::error!("mark: ElyTree did not open: {error}"); log::error!("mark: ElyTree did not open: {error}");
cx.update(|cx| { cx.update(|cx| {
@@ -176,7 +176,9 @@ mod tests {
fn spaces_stay_and_broken_repositories_say_why() { fn spaces_stay_and_broken_repositories_say_why() {
let dir = tempfile::tempdir().expect("a temp dir"); let dir = tempfile::tempdir().expect("a temp dir");
// Windows names end in no space. // Windows names end in no space.
let repo = dir.path().join(if cfg!(windows) { "re po" } else { "repo " }); let repo = dir
.path()
.join(if cfg!(windows) { "re po" } else { "repo " });
std::fs::create_dir(&repo).expect("the folder"); std::fs::create_dir(&repo).expect("the folder");
git(&repo, &["init", "-q"]); git(&repo, &["init", "-q"]);
std::fs::write(repo.join("t.md"), "a").expect("a file"); std::fs::write(repo.join("t.md"), "a").expect("a file");
@@ -193,11 +195,28 @@ mod tests {
let dir = tempfile::tempdir().expect("a temp dir"); let dir = tempfile::tempdir().expect("a temp dir");
let repo = dir.path(); let repo = dir.path();
git(repo, &["init", "-q"]); git(repo, &["init", "-q"]);
std::fs::write(repo.join(".gitignore"), "skip.md std::fs::write(
").expect("ignores"); repo.join(".gitignore"),
"skip.md
",
)
.expect("ignores");
std::fs::write(repo.join("t.md"), "a").expect("a file"); std::fs::write(repo.join("t.md"), "a").expect("a file");
git(repo, &["add", "."]); git(repo, &["add", "."]);
git(repo, &["-c", "user.name=T", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", "commit", "-qm", "one"]); git(
repo,
&[
"-c",
"user.name=T",
"-c",
"user.email=t@t",
"-c",
"commit.gpgsign=false",
"commit",
"-qm",
"one",
],
);
assert_eq!(ask(&repo.join("t.md")), Tracked::Unchanged); assert_eq!(ask(&repo.join("t.md")), Tracked::Unchanged);
std::fs::write(repo.join("t.md"), "b").expect("an edit"); std::fs::write(repo.join("t.md"), "b").expect("an edit");
assert_eq!(ask(&repo.join("t.md")), Tracked::Changed); assert_eq!(ask(&repo.join("t.md")), Tracked::Changed);
@@ -208,30 +227,60 @@ mod tests {
#[gpui::test] #[gpui::test]
fn the_status_item_follows_a_save(cx: &mut gpui::TestAppContext) { fn the_status_item_follows_a_save(cx: &mut gpui::TestAppContext) {
use ely_office::prelude::*; use ely_office::prelude::*;
let (data, dir) = (tempfile::tempdir().expect("data"), tempfile::tempdir().expect("repo")); let (data, dir) = (
tempfile::tempdir().expect("data"),
tempfile::tempdir().expect("repo"),
);
let repo = dir.path(); let repo = dir.path();
git(repo, &["init", "-q"]); git(repo, &["init", "-q"]);
std::fs::write(repo.join("t.md"), "a std::fs::write(
").expect("a file"); repo.join("t.md"),
"a
",
)
.expect("a file");
git(repo, &["add", "."]); git(repo, &["add", "."]);
git(repo, &["-c", "user.name=T", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", "commit", "-qm", "one"]); git(
repo,
&[
"-c",
"user.name=T",
"-c",
"user.email=t@t",
"-c",
"commit.gpgsign=false",
"commit",
"-qm",
"one",
],
);
let (desk, cx) = crate::desk::tests::start(cx, data.path()); let (desk, cx) = crate::desk::tests::start(cx, data.path());
crate::desk::tests::open(&desk, &repo.join("t.md"), cx); crate::desk::tests::open(&desk, &repo.join("t.md"), cx);
let said = |cx: &mut gpui::VisualTestContext| desk.read_with(cx, |desk, _| desk.tracked.clone()); let said =
|cx: &mut gpui::VisualTestContext| desk.read_with(cx, |desk, _| desk.tracked.clone());
assert_eq!(said(cx), Some(Tracked::Unchanged)); assert_eq!(said(cx), Some(Tracked::Unchanged));
let (id, view) = desk.read_with(cx, |desk, _| { let (id, view) = desk.read_with(cx, |desk, _| {
let tab = desk.active_tab().expect("a tab"); let tab = desk.active_tab().expect("a tab");
(tab.id, tab.view.clone()) (tab.id, tab.view.clone())
}); });
view.update(cx, |view, cx| view.adopt("b view.update(cx, |view, cx| {
".into(), cx)); view.adopt(
cx.executor().advance_clock(std::time::Duration::from_secs(1)); "b
"
.into(),
cx,
)
});
cx.executor()
.advance_clock(std::time::Duration::from_secs(1));
cx.run_until_parked(); cx.run_until_parked();
desk.update_in(cx, |desk, window, cx| desk.save(id, None, window, cx)); desk.update_in(cx, |desk, window, cx| desk.save(id, None, window, cx));
cx.run_until_parked(); cx.run_until_parked();
assert_eq!(std::fs::read_to_string(repo.join("t.md")).expect("saved"), "b assert_eq!(
"); std::fs::read_to_string(repo.join("t.md")).expect("saved"),
"b
"
);
assert_eq!(said(cx), Some(Tracked::Changed)); assert_eq!(said(cx), Some(Tracked::Changed));
} }
} }
+7 -2
View File
@@ -9,11 +9,16 @@ fn main() {
let app = env::var("CARGO_PKG_NAME").expect("cargo names the package"); let app = env::var("CARGO_PKG_NAME").expect("cargo names the package");
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("cargo names the folder")); let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("cargo names the folder"));
let icon = root.join("../../assets/icons").join(format!("{app}.ico")); let icon = root.join("../../assets/icons").join(format!("{app}.ico"));
let icon = fs::canonicalize(&icon).unwrap_or_else(|error| panic!("{}: {error}", icon.display())); let icon =
fs::canonicalize(&icon).unwrap_or_else(|error| panic!("{}: {error}", icon.display()));
println!("cargo:rerun-if-changed={}", icon.display()); println!("cargo:rerun-if-changed={}", icon.display());
// gpui's window icon is resource 1. // gpui's window icon is resource 1.
let rc = PathBuf::from(env::var("OUT_DIR").expect("cargo gives OUT_DIR")).join("icon.rc"); let rc = PathBuf::from(env::var("OUT_DIR").expect("cargo gives OUT_DIR")).join("icon.rc");
let path = icon.to_str().expect("a UTF-8 path").trim_start_matches(r"\\?\").replace('\\', "/"); let path = icon
.to_str()
.expect("a UTF-8 path")
.trim_start_matches(r"\\?\")
.replace('\\', "/");
fs::write(&rc, format!("1 ICON \"{path}\"\n")).expect("the resource script is written"); fs::write(&rc, format!("1 ICON \"{path}\"\n")).expect("the resource script is written");
embed_resource::compile(&rc, embed_resource::NONE) embed_resource::compile(&rc, embed_resource::NONE)
.manifest_optional() .manifest_optional()