add code editor

This commit is contained in:
2026-08-12 20:41:40 +07:00
parent 447888e2fb
commit 650afad6ba
3 changed files with 41 additions and 95 deletions
@@ -284,7 +284,7 @@ impl RepoDetailView {
}
/// Preview the file at `path` (relative to the worktree root).
fn open_file(&mut self, path: &str, _window: &mut Window, cx: &mut Context<Self>) {
fn open_file(&mut self, path: &str, window: &mut Window, cx: &mut Context<Self>) {
self.selected_file = Some(path.into());
if self.files.contains_key(path) || self.loading_files.contains(path) {
@@ -316,7 +316,7 @@ impl RepoDetailView {
self.load_commit(&path, cx);
let generation = self.ref_generation;
let task = cx.spawn(async move |this, cx| {
let task = cx.spawn_in(window, async move |this, cx| {
let path_for_read = path.clone();
let content = cx
.background_spawn(async move {
@@ -338,7 +338,7 @@ impl RepoDetailView {
})
.await;
this.update(cx, |this, cx| {
this.update_in(cx, |this, window, cx| {
// The worktree was switched while this file was reading;
// the result belongs to the previous branch.
if generation != this.ref_generation {
@@ -358,7 +358,7 @@ impl RepoDetailView {
let same = this.code.as_ref().map(|code| code.path.as_str())
== Some(path.as_str());
if !same {
this.set_code(path.clone().into(), text, cx);
this.set_code(path.clone().into(), text, window, cx);
}
}
}