Merge branch 'main' into zed2-project-test
Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
commit
291d35f337
607 changed files with 52667 additions and 14124 deletions
|
@ -16,6 +16,7 @@ test-support = [
|
|||
"settings2/test-support",
|
||||
"text/test-support",
|
||||
"prettier2/test-support",
|
||||
"gpui2/test-support",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -7,7 +7,7 @@ use anyhow::{anyhow, Context, Result};
|
|||
use async_trait::async_trait;
|
||||
use client2::proto::{self, PeerId};
|
||||
use futures::future;
|
||||
use gpui2::{AppContext, AsyncAppContext, Handle};
|
||||
use gpui2::{AppContext, AsyncAppContext, Model};
|
||||
use language2::{
|
||||
language_settings::{language_settings, InlayHintKind},
|
||||
point_from_lsp, point_to_lsp,
|
||||
|
@ -53,8 +53,8 @@ pub(crate) trait LspCommand: 'static + Sized + Send {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
message: <Self::LspRequest as lsp2::request::Request>::Result,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
cx: AsyncAppContext,
|
||||
) -> Result<Self::Response>;
|
||||
|
@ -63,8 +63,8 @@ pub(crate) trait LspCommand: 'static + Sized + Send {
|
|||
|
||||
async fn from_proto(
|
||||
message: Self::ProtoRequest,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
cx: AsyncAppContext,
|
||||
) -> Result<Self>;
|
||||
|
||||
|
@ -79,8 +79,8 @@ pub(crate) trait LspCommand: 'static + Sized + Send {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: <Self::ProtoRequest as proto::RequestMessage>::Response,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
cx: AsyncAppContext,
|
||||
) -> Result<Self::Response>;
|
||||
|
||||
|
@ -180,8 +180,8 @@ impl LspCommand for PrepareRename {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
message: Option<lsp2::PrepareRenameResponse>,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
_: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Option<Range<Anchor>>> {
|
||||
|
@ -215,8 +215,8 @@ impl LspCommand for PrepareRename {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::PrepareRename,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let position = message
|
||||
|
@ -256,8 +256,8 @@ impl LspCommand for PrepareRename {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::PrepareRenameResponse,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Option<Range<Anchor>>> {
|
||||
if message.can_rename {
|
||||
|
@ -307,8 +307,8 @@ impl LspCommand for PerformRename {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
message: Option<lsp2::WorkspaceEdit>,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<ProjectTransaction> {
|
||||
|
@ -343,8 +343,8 @@ impl LspCommand for PerformRename {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::PerformRename,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let position = message
|
||||
|
@ -379,8 +379,8 @@ impl LspCommand for PerformRename {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::PerformRenameResponse,
|
||||
project: Handle<Project>,
|
||||
_: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
_: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<ProjectTransaction> {
|
||||
let message = message
|
||||
|
@ -426,8 +426,8 @@ impl LspCommand for GetDefinition {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
message: Option<lsp2::GotoDefinitionResponse>,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
cx: AsyncAppContext,
|
||||
) -> Result<Vec<LocationLink>> {
|
||||
|
@ -447,8 +447,8 @@ impl LspCommand for GetDefinition {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::GetDefinition,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let position = message
|
||||
|
@ -479,8 +479,8 @@ impl LspCommand for GetDefinition {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::GetDefinitionResponse,
|
||||
project: Handle<Project>,
|
||||
_: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
_: Model<Buffer>,
|
||||
cx: AsyncAppContext,
|
||||
) -> Result<Vec<LocationLink>> {
|
||||
location_links_from_proto(message.links, project, cx).await
|
||||
|
@ -527,8 +527,8 @@ impl LspCommand for GetTypeDefinition {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
message: Option<lsp2::GotoTypeDefinitionResponse>,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
cx: AsyncAppContext,
|
||||
) -> Result<Vec<LocationLink>> {
|
||||
|
@ -548,8 +548,8 @@ impl LspCommand for GetTypeDefinition {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::GetTypeDefinition,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let position = message
|
||||
|
@ -580,8 +580,8 @@ impl LspCommand for GetTypeDefinition {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::GetTypeDefinitionResponse,
|
||||
project: Handle<Project>,
|
||||
_: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
_: Model<Buffer>,
|
||||
cx: AsyncAppContext,
|
||||
) -> Result<Vec<LocationLink>> {
|
||||
location_links_from_proto(message.links, project, cx).await
|
||||
|
@ -593,8 +593,8 @@ impl LspCommand for GetTypeDefinition {
|
|||
}
|
||||
|
||||
fn language_server_for_buffer(
|
||||
project: &Handle<Project>,
|
||||
buffer: &Handle<Buffer>,
|
||||
project: &Model<Project>,
|
||||
buffer: &Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
cx: &mut AsyncAppContext,
|
||||
) -> Result<(Arc<CachedLspAdapter>, Arc<LanguageServer>)> {
|
||||
|
@ -609,7 +609,7 @@ fn language_server_for_buffer(
|
|||
|
||||
async fn location_links_from_proto(
|
||||
proto_links: Vec<proto::LocationLink>,
|
||||
project: Handle<Project>,
|
||||
project: Model<Project>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<LocationLink>> {
|
||||
let mut links = Vec::new();
|
||||
|
@ -671,8 +671,8 @@ async fn location_links_from_proto(
|
|||
|
||||
async fn location_links_from_lsp(
|
||||
message: Option<lsp2::GotoDefinitionResponse>,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<LocationLink>> {
|
||||
|
@ -814,8 +814,8 @@ impl LspCommand for GetReferences {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
locations: Option<Vec<lsp2::Location>>,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<Location>> {
|
||||
|
@ -868,8 +868,8 @@ impl LspCommand for GetReferences {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::GetReferences,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let position = message
|
||||
|
@ -910,8 +910,8 @@ impl LspCommand for GetReferences {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::GetReferencesResponse,
|
||||
project: Handle<Project>,
|
||||
_: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
_: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<Location>> {
|
||||
let mut locations = Vec::new();
|
||||
|
@ -977,8 +977,8 @@ impl LspCommand for GetDocumentHighlights {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
lsp_highlights: Option<Vec<lsp2::DocumentHighlight>>,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
_: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<DocumentHighlight>> {
|
||||
|
@ -1016,8 +1016,8 @@ impl LspCommand for GetDocumentHighlights {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::GetDocumentHighlights,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let position = message
|
||||
|
@ -1060,8 +1060,8 @@ impl LspCommand for GetDocumentHighlights {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::GetDocumentHighlightsResponse,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<DocumentHighlight>> {
|
||||
let mut highlights = Vec::new();
|
||||
|
@ -1123,8 +1123,8 @@ impl LspCommand for GetHover {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
message: Option<lsp2::Hover>,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
_: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self::Response> {
|
||||
|
@ -1206,8 +1206,8 @@ impl LspCommand for GetHover {
|
|||
|
||||
async fn from_proto(
|
||||
message: Self::ProtoRequest,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let position = message
|
||||
|
@ -1272,8 +1272,8 @@ impl LspCommand for GetHover {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::GetHoverResponse,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self::Response> {
|
||||
let contents: Vec<_> = message
|
||||
|
@ -1341,8 +1341,8 @@ impl LspCommand for GetCompletions {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
completions: Option<lsp2::CompletionResponse>,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<Completion>> {
|
||||
|
@ -1484,8 +1484,8 @@ impl LspCommand for GetCompletions {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::GetCompletions,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let version = deserialize_version(&message.version);
|
||||
|
@ -1523,8 +1523,8 @@ impl LspCommand for GetCompletions {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::GetCompletionsResponse,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<Completion>> {
|
||||
buffer
|
||||
|
@ -1589,8 +1589,8 @@ impl LspCommand for GetCodeActions {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
actions: Option<lsp2::CodeActionResponse>,
|
||||
_: Handle<Project>,
|
||||
_: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
_: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
_: AsyncAppContext,
|
||||
) -> Result<Vec<CodeAction>> {
|
||||
|
@ -1623,8 +1623,8 @@ impl LspCommand for GetCodeActions {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::GetCodeActions,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let start = message
|
||||
|
@ -1663,8 +1663,8 @@ impl LspCommand for GetCodeActions {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::GetCodeActionsResponse,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<CodeAction>> {
|
||||
buffer
|
||||
|
@ -1726,8 +1726,8 @@ impl LspCommand for OnTypeFormatting {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
message: Option<Vec<lsp2::TextEdit>>,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Option<Transaction>> {
|
||||
|
@ -1763,8 +1763,8 @@ impl LspCommand for OnTypeFormatting {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::OnTypeFormatting,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let position = message
|
||||
|
@ -1805,8 +1805,8 @@ impl LspCommand for OnTypeFormatting {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::OnTypeFormattingResponse,
|
||||
_: Handle<Project>,
|
||||
_: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
_: Model<Buffer>,
|
||||
_: AsyncAppContext,
|
||||
) -> Result<Option<Transaction>> {
|
||||
let Some(transaction) = message.transaction else {
|
||||
|
@ -1825,7 +1825,7 @@ impl LspCommand for OnTypeFormatting {
|
|||
impl InlayHints {
|
||||
pub async fn lsp_to_project_hint(
|
||||
lsp_hint: lsp2::InlayHint,
|
||||
buffer_handle: &Handle<Buffer>,
|
||||
buffer_handle: &Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
resolve_state: ResolveState,
|
||||
force_no_type_left_padding: bool,
|
||||
|
@ -2230,8 +2230,8 @@ impl LspCommand for InlayHints {
|
|||
async fn response_from_lsp(
|
||||
self,
|
||||
message: Option<Vec<lsp2::InlayHint>>,
|
||||
project: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
project: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> anyhow::Result<Vec<InlayHint>> {
|
||||
|
@ -2286,8 +2286,8 @@ impl LspCommand for InlayHints {
|
|||
|
||||
async fn from_proto(
|
||||
message: proto::InlayHints,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self> {
|
||||
let start = message
|
||||
|
@ -2326,8 +2326,8 @@ impl LspCommand for InlayHints {
|
|||
async fn response_from_proto(
|
||||
self,
|
||||
message: proto::InlayHintsResponse,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: Model<Project>,
|
||||
buffer: Model<Buffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> anyhow::Result<Vec<InlayHint>> {
|
||||
buffer
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2275,7 +2275,7 @@ async fn test_definition(cx: &mut gpui2::TestAppContext) {
|
|||
});
|
||||
|
||||
fn list_worktrees<'a>(
|
||||
project: &'a Handle<Project>,
|
||||
project: &'a Model<Project>,
|
||||
cx: &'a AppContext,
|
||||
) -> Vec<(&'a Path, bool)> {
|
||||
project
|
||||
|
@ -4035,7 +4035,7 @@ fn test_glob_literal_prefix() {
|
|||
}
|
||||
|
||||
async fn search(
|
||||
project: &Handle<Project>,
|
||||
project: &Model<Project>,
|
||||
query: SearchQuery,
|
||||
cx: &mut gpui2::TestAppContext,
|
||||
) -> Result<HashMap<String, Vec<Range<usize>>>> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::Project;
|
||||
use gpui2::{AnyWindowHandle, Context, Handle, ModelContext, WeakHandle};
|
||||
use gpui2::{AnyWindowHandle, Context, Entity, Model, ModelContext, WeakModel};
|
||||
use settings2::Settings;
|
||||
use std::path::{Path, PathBuf};
|
||||
use terminal2::{
|
||||
|
@ -11,7 +11,7 @@ use terminal2::{
|
|||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
pub struct Terminals {
|
||||
pub(crate) local_handles: Vec<WeakHandle<terminal2::Terminal>>,
|
||||
pub(crate) local_handles: Vec<WeakModel<terminal2::Terminal>>,
|
||||
}
|
||||
|
||||
impl Project {
|
||||
|
@ -20,7 +20,7 @@ impl Project {
|
|||
working_directory: Option<PathBuf>,
|
||||
window: AnyWindowHandle,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> anyhow::Result<Handle<Terminal>> {
|
||||
) -> anyhow::Result<Model<Terminal>> {
|
||||
if self.is_remote() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"creating terminals as a guest is not supported yet"
|
||||
|
@ -40,7 +40,7 @@ impl Project {
|
|||
|_, _| todo!("color_for_index"),
|
||||
)
|
||||
.map(|builder| {
|
||||
let terminal_handle = cx.entity(|cx| builder.subscribe(cx));
|
||||
let terminal_handle = cx.build_model(|cx| builder.subscribe(cx));
|
||||
|
||||
self.terminals
|
||||
.local_handles
|
||||
|
@ -108,7 +108,7 @@ impl Project {
|
|||
fn activate_python_virtual_environment(
|
||||
&mut self,
|
||||
activate_script: Option<PathBuf>,
|
||||
terminal_handle: &Handle<Terminal>,
|
||||
terminal_handle: &Model<Terminal>,
|
||||
cx: &mut ModelContext<Project>,
|
||||
) {
|
||||
if let Some(activate_script) = activate_script {
|
||||
|
@ -121,7 +121,7 @@ impl Project {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn local_terminal_handles(&self) -> &Vec<WeakHandle<terminal2::Terminal>> {
|
||||
pub fn local_terminal_handles(&self) -> &Vec<WeakModel<terminal2::Terminal>> {
|
||||
&self.terminals.local_handles
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use futures::{
|
|||
use fuzzy2::CharBag;
|
||||
use git::{DOT_GIT, GITIGNORE};
|
||||
use gpui2::{
|
||||
AppContext, AsyncAppContext, Context, EventEmitter, Executor, Handle, ModelContext, Task,
|
||||
AppContext, AsyncAppContext, Context, EventEmitter, Executor, Model, ModelContext, Task,
|
||||
};
|
||||
use language2::{
|
||||
proto::{
|
||||
|
@ -292,7 +292,7 @@ impl Worktree {
|
|||
fs: Arc<dyn Fs>,
|
||||
next_entry_id: Arc<AtomicUsize>,
|
||||
cx: &mut AsyncAppContext,
|
||||
) -> Result<Handle<Self>> {
|
||||
) -> Result<Model<Self>> {
|
||||
// After determining whether the root entry is a file or a directory, populate the
|
||||
// snapshot's "root name", which will be used for the purpose of fuzzy matching.
|
||||
let abs_path = path.into();
|
||||
|
@ -301,7 +301,7 @@ impl Worktree {
|
|||
.await
|
||||
.context("failed to stat worktree path")?;
|
||||
|
||||
cx.entity(move |cx: &mut ModelContext<Worktree>| {
|
||||
cx.build_model(move |cx: &mut ModelContext<Worktree>| {
|
||||
let root_name = abs_path
|
||||
.file_name()
|
||||
.map_or(String::new(), |f| f.to_string_lossy().to_string());
|
||||
|
@ -406,8 +406,8 @@ impl Worktree {
|
|||
worktree: proto::WorktreeMetadata,
|
||||
client: Arc<Client>,
|
||||
cx: &mut AppContext,
|
||||
) -> Handle<Self> {
|
||||
cx.entity(|cx: &mut ModelContext<Self>| {
|
||||
) -> Model<Self> {
|
||||
cx.build_model(|cx: &mut ModelContext<Self>| {
|
||||
let snapshot = Snapshot {
|
||||
id: WorktreeId(worktree.id as usize),
|
||||
abs_path: Arc::from(PathBuf::from(worktree.abs_path)),
|
||||
|
@ -593,7 +593,7 @@ impl LocalWorktree {
|
|||
id: u64,
|
||||
path: &Path,
|
||||
cx: &mut ModelContext<Worktree>,
|
||||
) -> Task<Result<Handle<Buffer>>> {
|
||||
) -> Task<Result<Model<Buffer>>> {
|
||||
let path = Arc::from(path);
|
||||
cx.spawn(move |this, mut cx| async move {
|
||||
let (file, contents, diff_base) = this
|
||||
|
@ -603,7 +603,7 @@ impl LocalWorktree {
|
|||
.executor()
|
||||
.spawn(async move { text::Buffer::new(0, id, contents) })
|
||||
.await;
|
||||
cx.entity(|_| Buffer::build(text_buffer, diff_base, Some(Arc::new(file))))
|
||||
cx.build_model(|_| Buffer::build(text_buffer, diff_base, Some(Arc::new(file))))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -920,7 +920,7 @@ impl LocalWorktree {
|
|||
|
||||
pub fn save_buffer(
|
||||
&self,
|
||||
buffer_handle: Handle<Buffer>,
|
||||
buffer_handle: Model<Buffer>,
|
||||
path: Arc<Path>,
|
||||
has_changed_file: bool,
|
||||
cx: &mut ModelContext<Worktree>,
|
||||
|
@ -1331,7 +1331,7 @@ impl RemoteWorktree {
|
|||
|
||||
pub fn save_buffer(
|
||||
&self,
|
||||
buffer_handle: Handle<Buffer>,
|
||||
buffer_handle: Model<Buffer>,
|
||||
cx: &mut ModelContext<Worktree>,
|
||||
) -> Task<Result<()>> {
|
||||
let buffer = buffer_handle.read(cx);
|
||||
|
@ -2577,7 +2577,7 @@ impl fmt::Debug for Snapshot {
|
|||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct File {
|
||||
pub worktree: Handle<Worktree>,
|
||||
pub worktree: Model<Worktree>,
|
||||
pub path: Arc<Path>,
|
||||
pub mtime: SystemTime,
|
||||
pub(crate) entry_id: ProjectEntryId,
|
||||
|
@ -2659,12 +2659,12 @@ impl language2::File for File {
|
|||
|
||||
impl language2::LocalFile for File {
|
||||
fn abs_path(&self, cx: &AppContext) -> PathBuf {
|
||||
self.worktree
|
||||
.read(cx)
|
||||
.as_local()
|
||||
.unwrap()
|
||||
.abs_path
|
||||
.join(&self.path)
|
||||
let worktree_path = &self.worktree.read(cx).as_local().unwrap().abs_path;
|
||||
if self.path.as_ref() == Path::new("") {
|
||||
worktree_path.to_path_buf()
|
||||
} else {
|
||||
worktree_path.join(&self.path)
|
||||
}
|
||||
}
|
||||
|
||||
fn load(&self, cx: &AppContext) -> Task<Result<String>> {
|
||||
|
@ -2701,7 +2701,7 @@ impl language2::LocalFile for File {
|
|||
}
|
||||
|
||||
impl File {
|
||||
pub fn for_entry(entry: Entry, worktree: Handle<Worktree>) -> Arc<Self> {
|
||||
pub fn for_entry(entry: Entry, worktree: Model<Worktree>) -> Arc<Self> {
|
||||
Arc::new(Self {
|
||||
worktree,
|
||||
path: entry.path.clone(),
|
||||
|
@ -2714,7 +2714,7 @@ impl File {
|
|||
|
||||
pub fn from_proto(
|
||||
proto: rpc2::proto::File,
|
||||
worktree: Handle<Worktree>,
|
||||
worktree: Model<Worktree>,
|
||||
cx: &AppContext,
|
||||
) -> Result<Self> {
|
||||
let worktree_id = worktree
|
||||
|
@ -4038,7 +4038,7 @@ pub trait WorktreeModelHandle {
|
|||
) -> futures::future::LocalBoxFuture<'a, ()>;
|
||||
}
|
||||
|
||||
impl WorktreeModelHandle for Handle<Worktree> {
|
||||
impl WorktreeModelHandle for Model<Worktree> {
|
||||
// When the worktree's FS event stream sometimes delivers "redundant" events for FS changes that
|
||||
// occurred before the worktree was constructed. These events can cause the worktree to perform
|
||||
// extra directory scans, and emit extra scan-state notifications.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue