Checkpoint
This commit is contained in:
parent
9aaf7d0c46
commit
11953e613b
12 changed files with 507 additions and 404 deletions
|
@ -37,7 +37,7 @@ prettier2 = { path = "../prettier2" }
|
|||
rpc = { path = "../rpc" }
|
||||
settings2 = { path = "../settings2" }
|
||||
sum_tree = { path = "../sum_tree" }
|
||||
terminal = { path = "../terminal" }
|
||||
terminal2 = { path = "../terminal2" }
|
||||
util = { path = "../util" }
|
||||
|
||||
aho-corasick = "1.1"
|
||||
|
|
|
@ -32,8 +32,8 @@ pub fn lsp_formatting_options(tab_size: u32) -> lsp2::FormattingOptions {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
pub(crate) trait LspCommand: 'static + Sized {
|
||||
#[async_trait]
|
||||
pub(crate) trait LspCommand: 'static + Sized + Send {
|
||||
type Response: 'static + Default + Send;
|
||||
type LspRequest: 'static + Send + lsp2::request::Request;
|
||||
type ProtoRequest: 'static + Send + proto::RequestMessage;
|
||||
|
@ -148,7 +148,7 @@ impl From<lsp2::FormattingOptions> for FormattingOptions {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for PrepareRename {
|
||||
type Response = Option<Range<Anchor>>;
|
||||
type LspRequest = lsp2::request::PrepareRenameRequest;
|
||||
|
@ -183,7 +183,7 @@ impl LspCommand for PrepareRename {
|
|||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: LanguageServerId,
|
||||
cx: AsyncAppContext,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Option<Range<Anchor>>> {
|
||||
buffer.update(&mut cx, |buffer, _| {
|
||||
if let Some(
|
||||
|
@ -279,7 +279,7 @@ impl LspCommand for PrepareRename {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for PerformRename {
|
||||
type Response = ProjectTransaction;
|
||||
type LspRequest = lsp2::request::Rename;
|
||||
|
@ -398,7 +398,7 @@ impl LspCommand for PerformRename {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for GetDefinition {
|
||||
type Response = Vec<LocationLink>;
|
||||
type LspRequest = lsp2::request::GotoDefinition;
|
||||
|
@ -491,7 +491,7 @@ impl LspCommand for GetDefinition {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for GetTypeDefinition {
|
||||
type Response = Vec<LocationLink>;
|
||||
type LspRequest = lsp2::request::GotoTypeDefinition;
|
||||
|
@ -783,7 +783,7 @@ fn location_links_to_proto(
|
|||
.collect()
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for GetReferences {
|
||||
type Response = Vec<Location>;
|
||||
type LspRequest = lsp2::request::References;
|
||||
|
@ -836,17 +836,19 @@ impl LspCommand for GetReferences {
|
|||
})?
|
||||
.await?;
|
||||
|
||||
target_buffer_handle.update(&mut cx, |target_buffer, cx| {
|
||||
let target_start = target_buffer
|
||||
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
|
||||
let target_end = target_buffer
|
||||
.clip_point_utf16(point_from_lsp(lsp_location.range.end), Bias::Left);
|
||||
references.push(Location {
|
||||
buffer: target_buffer_handle,
|
||||
range: target_buffer.anchor_after(target_start)
|
||||
..target_buffer.anchor_before(target_end),
|
||||
});
|
||||
})?;
|
||||
target_buffer_handle
|
||||
.clone()
|
||||
.update(&mut cx, |target_buffer, _| {
|
||||
let target_start = target_buffer
|
||||
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
|
||||
let target_end = target_buffer
|
||||
.clip_point_utf16(point_from_lsp(lsp_location.range.end), Bias::Left);
|
||||
references.push(Location {
|
||||
buffer: target_buffer_handle,
|
||||
range: target_buffer.anchor_after(target_start)
|
||||
..target_buffer.anchor_before(target_end),
|
||||
});
|
||||
})?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -943,7 +945,7 @@ impl LspCommand for GetReferences {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for GetDocumentHighlights {
|
||||
type Response = Vec<DocumentHighlight>;
|
||||
type LspRequest = lsp2::request::DocumentHighlightRequest;
|
||||
|
@ -978,7 +980,7 @@ impl LspCommand for GetDocumentHighlights {
|
|||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
_: LanguageServerId,
|
||||
cx: AsyncAppContext,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<DocumentHighlight>> {
|
||||
buffer.update(&mut cx, |buffer, _| {
|
||||
let mut lsp_highlights = lsp_highlights.unwrap_or_default();
|
||||
|
@ -1094,7 +1096,7 @@ impl LspCommand for GetDocumentHighlights {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for GetHover {
|
||||
type Response = Option<Hover>;
|
||||
type LspRequest = lsp2::request::HoverRequest;
|
||||
|
@ -1130,7 +1132,7 @@ impl LspCommand for GetHover {
|
|||
return Ok(None);
|
||||
};
|
||||
|
||||
let (language, range) = buffer.update(&mut cx, |buffer, cx| {
|
||||
let (language, range) = buffer.update(&mut cx, |buffer, _| {
|
||||
(
|
||||
buffer.language().cloned(),
|
||||
hover.range.map(|range| {
|
||||
|
@ -1272,7 +1274,7 @@ impl LspCommand for GetHover {
|
|||
message: proto::GetHoverResponse,
|
||||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
cx: AsyncAppContext,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Self::Response> {
|
||||
let contents: Vec<_> = message
|
||||
.contents
|
||||
|
@ -1312,7 +1314,7 @@ impl LspCommand for GetHover {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for GetCompletions {
|
||||
type Response = Vec<Completion>;
|
||||
type LspRequest = lsp2::request::Completion;
|
||||
|
@ -1342,7 +1344,7 @@ impl LspCommand for GetCompletions {
|
|||
_: Handle<Project>,
|
||||
buffer: Handle<Buffer>,
|
||||
server_id: LanguageServerId,
|
||||
cx: AsyncAppContext,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<Vec<Completion>> {
|
||||
let mut response_list = None;
|
||||
let completions = if let Some(completions) = completions {
|
||||
|
@ -1543,7 +1545,7 @@ impl LspCommand for GetCompletions {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for GetCodeActions {
|
||||
type Response = Vec<CodeAction>;
|
||||
type LspRequest = lsp2::request::CodeActionRequest;
|
||||
|
@ -1682,7 +1684,7 @@ impl LspCommand for GetCodeActions {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for OnTypeFormatting {
|
||||
type Response = Option<Transaction>;
|
||||
type LspRequest = lsp2::request::OnTypeFormatting;
|
||||
|
@ -2190,7 +2192,7 @@ impl InlayHints {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
#[async_trait]
|
||||
impl LspCommand for InlayHints {
|
||||
type Response = Vec<InlayHint>;
|
||||
type LspRequest = lsp2::InlayHintRequest;
|
||||
|
@ -2253,7 +2255,7 @@ impl LspCommand for InlayHints {
|
|||
};
|
||||
|
||||
let buffer = buffer.clone();
|
||||
cx.spawn(|mut cx| async move {
|
||||
cx.spawn(move |mut cx| async move {
|
||||
InlayHints::lsp_to_project_hint(
|
||||
lsp_hint,
|
||||
&buffer,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
use crate::Project;
|
||||
use gpui2::{AnyWindowHandle, Handle, ModelContext, WeakHandle};
|
||||
use gpui2::{AnyWindowHandle, Context, Handle, ModelContext, WeakHandle};
|
||||
use std::path::{Path, PathBuf};
|
||||
use terminal::{
|
||||
use terminal2::{
|
||||
terminal_settings::{self, TerminalSettings, VenvSettingsContent},
|
||||
Terminal, TerminalBuilder,
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ use terminal::{
|
|||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
pub struct Terminals {
|
||||
pub(crate) local_handles: Vec<WeakHandle<terminal::Terminal>>,
|
||||
pub(crate) local_handles: Vec<WeakHandle<terminal2::Terminal>>,
|
||||
}
|
||||
|
||||
impl Project {
|
||||
|
@ -36,19 +36,23 @@ impl Project {
|
|||
Some(settings.blinking.clone()),
|
||||
settings.alternate_scroll,
|
||||
window,
|
||||
|index, cx| todo!("color_for_index"),
|
||||
)
|
||||
.map(|builder| {
|
||||
let terminal_handle = cx.add_model(|cx| builder.subscribe(cx));
|
||||
let terminal_handle = cx.entity(|cx| builder.subscribe(cx));
|
||||
|
||||
self.terminals
|
||||
.local_handles
|
||||
.push(terminal_handle.downgrade());
|
||||
|
||||
let id = terminal_handle.id();
|
||||
let id = terminal_handle.entity_id();
|
||||
cx.observe_release(&terminal_handle, move |project, _terminal, cx| {
|
||||
let handles = &mut project.terminals.local_handles;
|
||||
|
||||
if let Some(index) = handles.iter().position(|terminal| terminal.id() == id) {
|
||||
if let Some(index) = handles
|
||||
.iter()
|
||||
.position(|terminal| terminal.entity_id() == id)
|
||||
{
|
||||
handles.remove(index);
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -116,7 +120,7 @@ impl Project {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn local_terminal_handles(&self) -> &Vec<WeakHandle<terminal::Terminal>> {
|
||||
pub fn local_terminal_handles(&self) -> &Vec<WeakHandle<terminal2::Terminal>> {
|
||||
&self.terminals.local_handles
|
||||
}
|
||||
}
|
||||
|
|
|
@ -399,7 +399,7 @@ impl Worktree {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn remote<C: Context>(
|
||||
pub fn remote(
|
||||
project_remote_id: u64,
|
||||
replica_id: ReplicaId,
|
||||
worktree: proto::WorktreeMetadata,
|
||||
|
@ -935,7 +935,7 @@ impl LocalWorktree {
|
|||
let version = buffer.version();
|
||||
let save = self.write_file(path, text, buffer.line_ending(), cx);
|
||||
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
cx.spawn(move |this, mut cx| async move {
|
||||
let entry = save.await?;
|
||||
let this = this.upgrade().context("worktree dropped")?;
|
||||
|
||||
|
@ -1245,7 +1245,7 @@ impl LocalWorktree {
|
|||
.unbounded_send((self.snapshot(), Arc::from([]), Arc::from([])))
|
||||
.ok();
|
||||
|
||||
let worktree_id = cx.entity_id().;
|
||||
let worktree_id = cx.entity_id().as_u64();
|
||||
let _maintain_remote_snapshot = cx.executor().spawn(async move {
|
||||
let mut is_first = true;
|
||||
while let Some((snapshot, entry_changes, repo_changes)) = snapshots_rx.next().await {
|
||||
|
@ -1338,7 +1338,7 @@ impl RemoteWorktree {
|
|||
let version = buffer.version();
|
||||
let rpc = self.client.clone();
|
||||
let project_id = self.project_id;
|
||||
cx.spawn(|_, mut cx| async move {
|
||||
cx.spawn(move |_, mut cx| async move {
|
||||
let response = rpc
|
||||
.request(proto::SaveBuffer {
|
||||
project_id,
|
||||
|
@ -1446,7 +1446,7 @@ impl RemoteWorktree {
|
|||
cx: &mut ModelContext<Worktree>,
|
||||
) -> Task<Result<()>> {
|
||||
let wait_for_snapshot = self.wait_for_snapshot(scan_id);
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
cx.spawn(move |this, mut cx| async move {
|
||||
wait_for_snapshot.await?;
|
||||
this.update(&mut cx, |worktree, _| {
|
||||
let worktree = worktree.as_remote_mut().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue