This commit is contained in:
parent
e768eb0a34
commit
3e68f7fde4
10 changed files with 49 additions and 111 deletions
|
@ -177,34 +177,14 @@ fn commit_message_buffer(
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("creating commit message file {commit_message_file:?}"))?;
|
.with_context(|| format!("creating commit message file {commit_message_file:?}"))?;
|
||||||
let (worktree, relative_path) = project
|
let buffer = project
|
||||||
.update(&mut cx, |project, cx| {
|
.update(&mut cx, |project, cx| {
|
||||||
project.worktree_store().update(cx, |worktree_store, cx| {
|
project.open_local_buffer(&commit_message_file, cx)
|
||||||
worktree_store.find_or_create_worktree(&commit_message_file, false, cx)
|
|
||||||
})
|
|
||||||
})?
|
})?
|
||||||
.await
|
.await
|
||||||
.with_context(|| {
|
.with_context(|| {
|
||||||
format!("deriving worktree for commit message file {commit_message_file:?}")
|
format!("opening commit message buffer at {commit_message_file:?}",)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let buffer = project
|
|
||||||
.update(&mut cx, |project, cx| {
|
|
||||||
project.buffer_store().update(cx, |buffer_store, cx| {
|
|
||||||
buffer_store.open_buffer(
|
|
||||||
ProjectPath {
|
|
||||||
worktree_id: worktree.read(cx).id(),
|
|
||||||
path: Arc::from(relative_path),
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.with_context(|| {
|
|
||||||
format!("opening buffer for commit message file {commit_message_file:?}")
|
|
||||||
})?
|
|
||||||
.await?;
|
|
||||||
Ok(buffer)
|
Ok(buffer)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -278,6 +258,7 @@ impl GitPanel {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
|
commit_message_buffer: Option<Entity<Buffer>>,
|
||||||
cx: &mut Context<Workspace>,
|
cx: &mut Context<Workspace>,
|
||||||
) -> Entity<Self> {
|
) -> Entity<Self> {
|
||||||
let fs = workspace.app_state().fs.clone();
|
let fs = workspace.app_state().fs.clone();
|
||||||
|
@ -294,7 +275,12 @@ impl GitPanel {
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
let commit_editor = cx.new(|cx| commit_message_editor(None, window, cx));
|
let commit_editor =
|
||||||
|
cx.new(|cx| commit_message_editor(commit_message_buffer, window, cx));
|
||||||
|
commit_editor.update(cx, |editor, cx| {
|
||||||
|
editor.clear(window, cx);
|
||||||
|
});
|
||||||
|
|
||||||
let scroll_handle = UniformListScrollHandle::new();
|
let scroll_handle = UniformListScrollHandle::new();
|
||||||
|
|
||||||
cx.subscribe_in(
|
cx.subscribe_in(
|
||||||
|
|
|
@ -329,7 +329,6 @@ impl RemoteBufferStore {
|
||||||
&self,
|
&self,
|
||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
worktree: Entity<Worktree>,
|
worktree: Entity<Worktree>,
|
||||||
skip_file_contents: bool,
|
|
||||||
cx: &mut Context<BufferStore>,
|
cx: &mut Context<BufferStore>,
|
||||||
) -> Task<Result<Entity<Buffer>>> {
|
) -> Task<Result<Entity<Buffer>>> {
|
||||||
let worktree_id = worktree.read(cx).id().to_proto();
|
let worktree_id = worktree.read(cx).id().to_proto();
|
||||||
|
@ -342,7 +341,6 @@ impl RemoteBufferStore {
|
||||||
project_id,
|
project_id,
|
||||||
worktree_id,
|
worktree_id,
|
||||||
path: path_string,
|
path: path_string,
|
||||||
skip_file_contents,
|
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
let buffer_id = BufferId::new(response.buffer_id)?;
|
let buffer_id = BufferId::new(response.buffer_id)?;
|
||||||
|
@ -788,11 +786,10 @@ impl LocalBufferStore {
|
||||||
&self,
|
&self,
|
||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
worktree: Entity<Worktree>,
|
worktree: Entity<Worktree>,
|
||||||
skip_file_contents: bool,
|
|
||||||
cx: &mut Context<BufferStore>,
|
cx: &mut Context<BufferStore>,
|
||||||
) -> Task<Result<Entity<Buffer>>> {
|
) -> Task<Result<Entity<Buffer>>> {
|
||||||
let load_buffer = worktree.update(cx, |worktree, cx| {
|
let load_buffer = worktree.update(cx, |worktree, cx| {
|
||||||
let load_file = worktree.load_file(path.as_ref(), skip_file_contents, cx);
|
let load_file = worktree.load_file(path.as_ref(), cx);
|
||||||
let reservation = cx.reserve_entity();
|
let reservation = cx.reserve_entity();
|
||||||
let buffer_id = BufferId::from(reservation.entity_id().as_non_zero_u64());
|
let buffer_id = BufferId::from(reservation.entity_id().as_non_zero_u64());
|
||||||
cx.spawn(move |_, mut cx| async move {
|
cx.spawn(move |_, mut cx| async move {
|
||||||
|
@ -976,7 +973,6 @@ impl BufferStore {
|
||||||
pub fn open_buffer(
|
pub fn open_buffer(
|
||||||
&mut self,
|
&mut self,
|
||||||
project_path: ProjectPath,
|
project_path: ProjectPath,
|
||||||
skip_file_contents: bool,
|
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Task<Result<Entity<Buffer>>> {
|
) -> Task<Result<Entity<Buffer>>> {
|
||||||
if let Some(buffer) = self.get_by_path(&project_path, cx) {
|
if let Some(buffer) = self.get_by_path(&project_path, cx) {
|
||||||
|
@ -995,12 +991,8 @@ impl BufferStore {
|
||||||
return Task::ready(Err(anyhow!("no such worktree")));
|
return Task::ready(Err(anyhow!("no such worktree")));
|
||||||
};
|
};
|
||||||
let load_buffer = match &self.state {
|
let load_buffer = match &self.state {
|
||||||
BufferStoreState::Local(this) => {
|
BufferStoreState::Local(this) => this.open_buffer(path, worktree, cx),
|
||||||
this.open_buffer(path, worktree, skip_file_contents, cx)
|
BufferStoreState::Remote(this) => this.open_buffer(path, worktree, cx),
|
||||||
}
|
|
||||||
BufferStoreState::Remote(this) => {
|
|
||||||
this.open_buffer(path, worktree, skip_file_contents, cx)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
entry
|
entry
|
||||||
|
@ -1493,7 +1485,7 @@ impl BufferStore {
|
||||||
let buffers = this.update(&mut cx, |this, cx| {
|
let buffers = this.update(&mut cx, |this, cx| {
|
||||||
project_paths
|
project_paths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|project_path| this.open_buffer(project_path, false, cx))
|
.map(|project_path| this.open_buffer(project_path, cx))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
})?;
|
})?;
|
||||||
for buffer_task in buffers {
|
for buffer_task in buffers {
|
||||||
|
|
|
@ -5616,7 +5616,7 @@ impl LspStore {
|
||||||
lsp_store
|
lsp_store
|
||||||
.update(&mut cx, |lsp_store, cx| {
|
.update(&mut cx, |lsp_store, cx| {
|
||||||
lsp_store.buffer_store().update(cx, |buffer_store, cx| {
|
lsp_store.buffer_store().update(cx, |buffer_store, cx| {
|
||||||
buffer_store.open_buffer(project_path, false, cx)
|
buffer_store.open_buffer(project_path, cx)
|
||||||
})
|
})
|
||||||
})?
|
})?
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -1935,21 +1935,7 @@ impl Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||||
buffer_store.open_buffer(path.into(), false, cx)
|
buffer_store.open_buffer(path.into(), cx)
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn open_buffer_without_contents(
|
|
||||||
&mut self,
|
|
||||||
path: impl Into<ProjectPath>,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) -> Task<Result<Entity<Buffer>>> {
|
|
||||||
if self.is_disconnected(cx) {
|
|
||||||
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
|
||||||
buffer_store.open_buffer(path.into(), true, cx)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3953,17 +3939,7 @@ impl Project {
|
||||||
) -> Result<proto::OpenBufferResponse> {
|
) -> Result<proto::OpenBufferResponse> {
|
||||||
let peer_id = envelope.original_sender_id()?;
|
let peer_id = envelope.original_sender_id()?;
|
||||||
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
|
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
|
||||||
let skip_file_contents = envelope.payload.skip_file_contents;
|
|
||||||
let open_buffer = this.update(&mut cx, |this, cx| {
|
let open_buffer = this.update(&mut cx, |this, cx| {
|
||||||
if skip_file_contents {
|
|
||||||
this.open_buffer_without_contents(
|
|
||||||
ProjectPath {
|
|
||||||
worktree_id,
|
|
||||||
path: PathBuf::from(envelope.payload.path).into(),
|
|
||||||
},
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
this.open_buffer(
|
this.open_buffer(
|
||||||
ProjectPath {
|
ProjectPath {
|
||||||
worktree_id,
|
worktree_id,
|
||||||
|
@ -3971,7 +3947,6 @@ impl Project {
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let buffer = open_buffer.await?;
|
let buffer = open_buffer.await?;
|
||||||
|
@ -4079,8 +4054,10 @@ impl Project {
|
||||||
.with_context(|| format!("creating commit message file {commit_message_file:?}"))?;
|
.with_context(|| format!("creating commit message file {commit_message_file:?}"))?;
|
||||||
|
|
||||||
let (worktree, relative_path) = this
|
let (worktree, relative_path) = this
|
||||||
.update(&mut cx, |project, cx| {
|
.update(&mut cx, |headless_project, cx| {
|
||||||
project.worktree_store.update(cx, |worktree_store, cx| {
|
headless_project
|
||||||
|
.worktree_store
|
||||||
|
.update(cx, |worktree_store, cx| {
|
||||||
worktree_store.find_or_create_worktree(&commit_message_file, false, cx)
|
worktree_store.find_or_create_worktree(&commit_message_file, false, cx)
|
||||||
})
|
})
|
||||||
})?
|
})?
|
||||||
|
@ -4090,14 +4067,15 @@ impl Project {
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let buffer = this
|
let buffer = this
|
||||||
.update(&mut cx, |project, cx| {
|
.update(&mut cx, |headless_project, cx| {
|
||||||
project.buffer_store.update(cx, |buffer_store, cx| {
|
headless_project
|
||||||
|
.buffer_store
|
||||||
|
.update(cx, |buffer_store, cx| {
|
||||||
buffer_store.open_buffer(
|
buffer_store.open_buffer(
|
||||||
ProjectPath {
|
ProjectPath {
|
||||||
worktree_id: worktree.read(cx).id(),
|
worktree_id: worktree.read(cx).id(),
|
||||||
path: Arc::from(relative_path),
|
path: Arc::from(relative_path),
|
||||||
},
|
},
|
||||||
true,
|
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -795,7 +795,6 @@ message OpenBufferByPath {
|
||||||
uint64 project_id = 1;
|
uint64 project_id = 1;
|
||||||
uint64 worktree_id = 2;
|
uint64 worktree_id = 2;
|
||||||
string path = 3;
|
string path = 3;
|
||||||
bool skip_file_contents = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message OpenBufferById {
|
message OpenBufferById {
|
||||||
|
|
|
@ -420,7 +420,6 @@ impl HeadlessProject {
|
||||||
worktree_id,
|
worktree_id,
|
||||||
path: PathBuf::from(message.payload.path).into(),
|
path: PathBuf::from(message.payload.path).into(),
|
||||||
},
|
},
|
||||||
message.payload.skip_file_contents,
|
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -487,7 +486,6 @@ impl HeadlessProject {
|
||||||
worktree_id: worktree.read(cx).id(),
|
worktree_id: worktree.read(cx).id(),
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
},
|
},
|
||||||
false,
|
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -731,7 +729,6 @@ impl HeadlessProject {
|
||||||
worktree_id: worktree.read(cx).id(),
|
worktree_id: worktree.read(cx).id(),
|
||||||
path: Arc::from(relative_path),
|
path: Arc::from(relative_path),
|
||||||
},
|
},
|
||||||
true,
|
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -862,14 +862,9 @@ impl Worktree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_file(
|
pub fn load_file(&self, path: &Path, cx: &Context<Worktree>) -> Task<Result<LoadedFile>> {
|
||||||
&self,
|
|
||||||
path: &Path,
|
|
||||||
skip_file_contents: bool,
|
|
||||||
cx: &Context<Worktree>,
|
|
||||||
) -> Task<Result<LoadedFile>> {
|
|
||||||
match self {
|
match self {
|
||||||
Worktree::Local(this) => this.load_file(path, skip_file_contents, cx),
|
Worktree::Local(this) => this.load_file(path, cx),
|
||||||
Worktree::Remote(_) => {
|
Worktree::Remote(_) => {
|
||||||
Task::ready(Err(anyhow!("remote worktrees can't yet load files")))
|
Task::ready(Err(anyhow!("remote worktrees can't yet load files")))
|
||||||
}
|
}
|
||||||
|
@ -1587,12 +1582,7 @@ impl LocalWorktree {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_file(
|
fn load_file(&self, path: &Path, cx: &Context<Worktree>) -> Task<Result<LoadedFile>> {
|
||||||
&self,
|
|
||||||
path: &Path,
|
|
||||||
skip_file_contents: bool,
|
|
||||||
cx: &Context<Worktree>,
|
|
||||||
) -> Task<Result<LoadedFile>> {
|
|
||||||
let path = Arc::from(path);
|
let path = Arc::from(path);
|
||||||
let abs_path = self.absolutize(&path);
|
let abs_path = self.absolutize(&path);
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
|
@ -1601,11 +1591,7 @@ impl LocalWorktree {
|
||||||
|
|
||||||
cx.spawn(|this, _cx| async move {
|
cx.spawn(|this, _cx| async move {
|
||||||
let abs_path = abs_path?;
|
let abs_path = abs_path?;
|
||||||
let text = if skip_file_contents {
|
let text = fs.load(&abs_path).await?;
|
||||||
String::new()
|
|
||||||
} else {
|
|
||||||
fs.load(&abs_path).await?
|
|
||||||
};
|
|
||||||
|
|
||||||
let worktree = this
|
let worktree = this
|
||||||
.upgrade()
|
.upgrade()
|
||||||
|
|
|
@ -467,7 +467,7 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) {
|
||||||
let prev_read_dir_count = fs.read_dir_call_count();
|
let prev_read_dir_count = fs.read_dir_call_count();
|
||||||
let loaded = tree
|
let loaded = tree
|
||||||
.update(cx, |tree, cx| {
|
.update(cx, |tree, cx| {
|
||||||
tree.load_file("one/node_modules/b/b1.js".as_ref(), false, cx)
|
tree.load_file("one/node_modules/b/b1.js".as_ref(), cx)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -507,7 +507,7 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) {
|
||||||
let prev_read_dir_count = fs.read_dir_call_count();
|
let prev_read_dir_count = fs.read_dir_call_count();
|
||||||
let loaded = tree
|
let loaded = tree
|
||||||
.update(cx, |tree, cx| {
|
.update(cx, |tree, cx| {
|
||||||
tree.load_file("one/node_modules/a/a2.js".as_ref(), false, cx)
|
tree.load_file("one/node_modules/a/a2.js".as_ref(), cx)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -404,7 +404,7 @@ fn initialize_panels(
|
||||||
workspace.add_panel(chat_panel, window, cx);
|
workspace.add_panel(chat_panel, window, cx);
|
||||||
workspace.add_panel(notification_panel, window, cx);
|
workspace.add_panel(notification_panel, window, cx);
|
||||||
cx.when_flag_enabled::<GitUiFeatureFlag>(window, |workspace, window, cx| {
|
cx.when_flag_enabled::<GitUiFeatureFlag>(window, |workspace, window, cx| {
|
||||||
let git_panel = git_ui::git_panel::GitPanel::new(workspace, window, cx);
|
let git_panel = git_ui::git_panel::GitPanel::new(workspace, window, None, cx);
|
||||||
workspace.add_panel(git_panel, window, cx);
|
workspace.add_panel(git_panel, window, cx);
|
||||||
});
|
});
|
||||||
})?;
|
})?;
|
||||||
|
|
|
@ -952,7 +952,7 @@ impl LicenseDetectionWatcher {
|
||||||
pub fn new(worktree: &Worktree, cx: &mut Context<Worktree>) -> Self {
|
pub fn new(worktree: &Worktree, cx: &mut Context<Worktree>) -> Self {
|
||||||
let (mut is_open_source_tx, is_open_source_rx) = watch::channel_with::<bool>(false);
|
let (mut is_open_source_tx, is_open_source_rx) = watch::channel_with::<bool>(false);
|
||||||
|
|
||||||
let loaded_file_fut = worktree.load_file(Path::new("LICENSE"), false, cx);
|
let loaded_file_fut = worktree.load_file(Path::new("LICENSE"), cx);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
is_open_source_rx,
|
is_open_source_rx,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue