parent
e3b593efbd
commit
c4083b9b63
28 changed files with 103 additions and 104 deletions
|
@ -832,6 +832,7 @@ redundant_closure = { level = "deny" }
|
||||||
declare_interior_mutable_const = { level = "deny" }
|
declare_interior_mutable_const = { level = "deny" }
|
||||||
collapsible_if = { level = "warn"}
|
collapsible_if = { level = "warn"}
|
||||||
needless_borrow = { level = "warn"}
|
needless_borrow = { level = "warn"}
|
||||||
|
unnecessary_mut_passed = {level = "warn"}
|
||||||
# Individual rules that have violations in the codebase:
|
# Individual rules that have violations in the codebase:
|
||||||
type_complexity = "allow"
|
type_complexity = "allow"
|
||||||
# We often return trait objects from `new` functions.
|
# We often return trait objects from `new` functions.
|
||||||
|
|
|
@ -2173,7 +2173,7 @@ mod tests {
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
editor.read_with(&mut cx, |editor, cx| {
|
editor.read_with(&cx, |editor, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"Lorem [@one.txt](file:///dir/a/one.txt) Ipsum [@eight.txt](file:///dir/b/eight.txt) [@MySymbol](file:///dir/a/one.txt?symbol=MySymbol#L1:1) "
|
"Lorem [@one.txt](file:///dir/a/one.txt) Ipsum [@eight.txt](file:///dir/b/eight.txt) [@MySymbol](file:///dir/a/one.txt?symbol=MySymbol#L1:1) "
|
||||||
|
|
|
@ -320,7 +320,7 @@ impl ContextStore {
|
||||||
.client
|
.client
|
||||||
.subscribe_to_entity(remote_id)
|
.subscribe_to_entity(remote_id)
|
||||||
.log_err()
|
.log_err()
|
||||||
.map(|subscription| subscription.set_entity(&cx.entity(), &mut cx.to_async()));
|
.map(|subscription| subscription.set_entity(&cx.entity(), &cx.to_async()));
|
||||||
self.advertise_contexts(cx);
|
self.advertise_contexts(cx);
|
||||||
} else {
|
} else {
|
||||||
self.client_subscription = None;
|
self.client_subscription = None;
|
||||||
|
|
|
@ -543,7 +543,7 @@ impl AutoUpdater {
|
||||||
|
|
||||||
async fn update(this: Entity<Self>, mut cx: AsyncApp) -> Result<()> {
|
async fn update(this: Entity<Self>, mut cx: AsyncApp) -> Result<()> {
|
||||||
let (client, installed_version, previous_status, release_channel) =
|
let (client, installed_version, previous_status, release_channel) =
|
||||||
this.read_with(&mut cx, |this, cx| {
|
this.read_with(&cx, |this, cx| {
|
||||||
(
|
(
|
||||||
this.http_client.clone(),
|
this.http_client.clone(),
|
||||||
this.current_version,
|
this.current_version,
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl ActiveCall {
|
||||||
envelope: TypedEnvelope<proto::IncomingCall>,
|
envelope: TypedEnvelope<proto::IncomingCall>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::Ack> {
|
) -> Result<proto::Ack> {
|
||||||
let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
|
let user_store = this.read_with(&cx, |this, _| this.user_store.clone())?;
|
||||||
let call = IncomingCall {
|
let call = IncomingCall {
|
||||||
room_id: envelope.payload.room_id,
|
room_id: envelope.payload.room_id,
|
||||||
participants: user_store
|
participants: user_store
|
||||||
|
|
|
@ -82,7 +82,7 @@ impl ChannelBuffer {
|
||||||
collaborators: Default::default(),
|
collaborators: Default::default(),
|
||||||
acknowledge_task: None,
|
acknowledge_task: None,
|
||||||
channel_id: channel.id,
|
channel_id: channel.id,
|
||||||
subscription: Some(subscription.set_entity(&cx.entity(), &mut cx.to_async())),
|
subscription: Some(subscription.set_entity(&cx.entity(), &cx.to_async())),
|
||||||
user_store,
|
user_store,
|
||||||
channel_store,
|
channel_store,
|
||||||
};
|
};
|
||||||
|
@ -110,7 +110,7 @@ impl ChannelBuffer {
|
||||||
let Ok(subscription) = self.client.subscribe_to_entity(self.channel_id.0) else {
|
let Ok(subscription) = self.client.subscribe_to_entity(self.channel_id.0) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
self.subscription = Some(subscription.set_entity(&cx.entity(), &mut cx.to_async()));
|
self.subscription = Some(subscription.set_entity(&cx.entity(), &cx.to_async()));
|
||||||
cx.emit(ChannelBufferEvent::Connected);
|
cx.emit(ChannelBufferEvent::Connected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,7 +532,7 @@ impl ChannelChat {
|
||||||
message: TypedEnvelope<proto::ChannelMessageSent>,
|
message: TypedEnvelope<proto::ChannelMessageSent>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
|
let user_store = this.read_with(&cx, |this, _| this.user_store.clone())?;
|
||||||
let message = message.payload.message.context("empty message")?;
|
let message = message.payload.message.context("empty message")?;
|
||||||
let message_id = message.id;
|
let message_id = message.id;
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ impl ChannelChat {
|
||||||
message: TypedEnvelope<proto::ChannelMessageUpdate>,
|
message: TypedEnvelope<proto::ChannelMessageUpdate>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
|
let user_store = this.read_with(&cx, |this, _| this.user_store.clone())?;
|
||||||
let message = message.payload.message.context("empty message")?;
|
let message = message.payload.message.context("empty message")?;
|
||||||
|
|
||||||
let message = ChannelMessage::from_proto(message, &user_store, &mut cx).await?;
|
let message = ChannelMessage::from_proto(message, &user_store, &mut cx).await?;
|
||||||
|
|
|
@ -908,9 +908,9 @@ impl ChannelStore {
|
||||||
async fn handle_update_channels(
|
async fn handle_update_channels(
|
||||||
this: Entity<Self>,
|
this: Entity<Self>,
|
||||||
message: TypedEnvelope<proto::UpdateChannels>,
|
message: TypedEnvelope<proto::UpdateChannels>,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
this.read_with(&mut cx, |this, _| {
|
this.read_with(&cx, |this, _| {
|
||||||
this.update_channels_tx
|
this.update_channels_tx
|
||||||
.unbounded_send(message.payload)
|
.unbounded_send(message.payload)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -2073,8 +2073,8 @@ mod tests {
|
||||||
let (done_tx1, done_rx1) = smol::channel::unbounded();
|
let (done_tx1, done_rx1) = smol::channel::unbounded();
|
||||||
let (done_tx2, done_rx2) = smol::channel::unbounded();
|
let (done_tx2, done_rx2) = smol::channel::unbounded();
|
||||||
AnyProtoClient::from(client.clone()).add_entity_message_handler(
|
AnyProtoClient::from(client.clone()).add_entity_message_handler(
|
||||||
move |entity: Entity<TestEntity>, _: TypedEnvelope<proto::JoinProject>, mut cx| {
|
move |entity: Entity<TestEntity>, _: TypedEnvelope<proto::JoinProject>, cx| {
|
||||||
match entity.read_with(&mut cx, |entity, _| entity.id).unwrap() {
|
match entity.read_with(&cx, |entity, _| entity.id).unwrap() {
|
||||||
1 => done_tx1.try_send(()).unwrap(),
|
1 => done_tx1.try_send(()).unwrap(),
|
||||||
2 => done_tx2.try_send(()).unwrap(),
|
2 => done_tx2.try_send(()).unwrap(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -2098,17 +2098,17 @@ mod tests {
|
||||||
let _subscription1 = client
|
let _subscription1 = client
|
||||||
.subscribe_to_entity(1)
|
.subscribe_to_entity(1)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_entity(&entity1, &mut cx.to_async());
|
.set_entity(&entity1, &cx.to_async());
|
||||||
let _subscription2 = client
|
let _subscription2 = client
|
||||||
.subscribe_to_entity(2)
|
.subscribe_to_entity(2)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_entity(&entity2, &mut cx.to_async());
|
.set_entity(&entity2, &cx.to_async());
|
||||||
// Ensure dropping a subscription for the same entity type still allows receiving of
|
// Ensure dropping a subscription for the same entity type still allows receiving of
|
||||||
// messages for other entity IDs of the same type.
|
// messages for other entity IDs of the same type.
|
||||||
let subscription3 = client
|
let subscription3 = client
|
||||||
.subscribe_to_entity(3)
|
.subscribe_to_entity(3)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_entity(&entity3, &mut cx.to_async());
|
.set_entity(&entity3, &cx.to_async());
|
||||||
drop(subscription3);
|
drop(subscription3);
|
||||||
|
|
||||||
server.send(proto::JoinProject {
|
server.send(proto::JoinProject {
|
||||||
|
|
|
@ -332,9 +332,9 @@ impl UserStore {
|
||||||
async fn handle_update_contacts(
|
async fn handle_update_contacts(
|
||||||
this: Entity<Self>,
|
this: Entity<Self>,
|
||||||
message: TypedEnvelope<proto::UpdateContacts>,
|
message: TypedEnvelope<proto::UpdateContacts>,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
this.read_with(&mut cx, |this, _| {
|
this.read_with(&cx, |this, _| {
|
||||||
this.update_contacts_tx
|
this.update_contacts_tx
|
||||||
.unbounded_send(UpdateContacts::Update(message.payload))
|
.unbounded_send(UpdateContacts::Update(message.payload))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -655,11 +655,11 @@ pub fn show_link_definition(
|
||||||
pub(crate) fn find_url(
|
pub(crate) fn find_url(
|
||||||
buffer: &Entity<language::Buffer>,
|
buffer: &Entity<language::Buffer>,
|
||||||
position: text::Anchor,
|
position: text::Anchor,
|
||||||
mut cx: AsyncWindowContext,
|
cx: AsyncWindowContext,
|
||||||
) -> Option<(Range<text::Anchor>, String)> {
|
) -> Option<(Range<text::Anchor>, String)> {
|
||||||
const LIMIT: usize = 2048;
|
const LIMIT: usize = 2048;
|
||||||
|
|
||||||
let Ok(snapshot) = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot()) else {
|
let Ok(snapshot) = buffer.read_with(&cx, |buffer, _| buffer.snapshot()) else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -717,11 +717,11 @@ pub(crate) fn find_url(
|
||||||
pub(crate) fn find_url_from_range(
|
pub(crate) fn find_url_from_range(
|
||||||
buffer: &Entity<language::Buffer>,
|
buffer: &Entity<language::Buffer>,
|
||||||
range: Range<text::Anchor>,
|
range: Range<text::Anchor>,
|
||||||
mut cx: AsyncWindowContext,
|
cx: AsyncWindowContext,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
const LIMIT: usize = 2048;
|
const LIMIT: usize = 2048;
|
||||||
|
|
||||||
let Ok(snapshot) = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot()) else {
|
let Ok(snapshot) = buffer.read_with(&cx, |buffer, _| buffer.snapshot()) else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -368,7 +368,7 @@ impl App {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
init_app_menus(platform.as_ref(), &mut app.borrow_mut());
|
init_app_menus(platform.as_ref(), &app.borrow());
|
||||||
|
|
||||||
platform.on_keyboard_layout_change(Box::new({
|
platform.on_keyboard_layout_change(Box::new({
|
||||||
let app = Rc::downgrade(&app);
|
let app = Rc::downgrade(&app);
|
||||||
|
@ -1332,7 +1332,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
inner(
|
inner(
|
||||||
&mut self.keystroke_observers,
|
&self.keystroke_observers,
|
||||||
Box::new(move |event, window, cx| {
|
Box::new(move |event, window, cx| {
|
||||||
f(event, window, cx);
|
f(event, window, cx);
|
||||||
true
|
true
|
||||||
|
@ -1358,7 +1358,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
inner(
|
inner(
|
||||||
&mut self.keystroke_interceptors,
|
&self.keystroke_interceptors,
|
||||||
Box::new(move |event, window, cx| {
|
Box::new(move |event, window, cx| {
|
||||||
f(event, window, cx);
|
f(event, window, cx);
|
||||||
true
|
true
|
||||||
|
|
|
@ -472,7 +472,7 @@ impl<'a, T: 'static> Context<'a, T> {
|
||||||
|
|
||||||
let view = self.weak_entity();
|
let view = self.weak_entity();
|
||||||
inner(
|
inner(
|
||||||
&mut self.keystroke_observers,
|
&self.keystroke_observers,
|
||||||
Box::new(move |event, window, cx| {
|
Box::new(move |event, window, cx| {
|
||||||
if let Some(view) = view.upgrade() {
|
if let Some(view) = view.upgrade() {
|
||||||
view.update(cx, |view, cx| f(view, event, window, cx));
|
view.update(cx, |view, cx| f(view, event, window, cx));
|
||||||
|
|
|
@ -219,7 +219,7 @@ impl TestAppContext {
|
||||||
let mut cx = self.app.borrow_mut();
|
let mut cx = self.app.borrow_mut();
|
||||||
|
|
||||||
// Some tests rely on the window size matching the bounds of the test display
|
// Some tests rely on the window size matching the bounds of the test display
|
||||||
let bounds = Bounds::maximized(None, &mut cx);
|
let bounds = Bounds::maximized(None, &cx);
|
||||||
cx.open_window(
|
cx.open_window(
|
||||||
WindowOptions {
|
WindowOptions {
|
||||||
window_bounds: Some(WindowBounds::Windowed(bounds)),
|
window_bounds: Some(WindowBounds::Windowed(bounds)),
|
||||||
|
@ -233,7 +233,7 @@ impl TestAppContext {
|
||||||
/// Adds a new window with no content.
|
/// Adds a new window with no content.
|
||||||
pub fn add_empty_window(&mut self) -> &mut VisualTestContext {
|
pub fn add_empty_window(&mut self) -> &mut VisualTestContext {
|
||||||
let mut cx = self.app.borrow_mut();
|
let mut cx = self.app.borrow_mut();
|
||||||
let bounds = Bounds::maximized(None, &mut cx);
|
let bounds = Bounds::maximized(None, &cx);
|
||||||
let window = cx
|
let window = cx
|
||||||
.open_window(
|
.open_window(
|
||||||
WindowOptions {
|
WindowOptions {
|
||||||
|
@ -261,7 +261,7 @@ impl TestAppContext {
|
||||||
V: 'static + Render,
|
V: 'static + Render,
|
||||||
{
|
{
|
||||||
let mut cx = self.app.borrow_mut();
|
let mut cx = self.app.borrow_mut();
|
||||||
let bounds = Bounds::maximized(None, &mut cx);
|
let bounds = Bounds::maximized(None, &cx);
|
||||||
let window = cx
|
let window = cx
|
||||||
.open_window(
|
.open_window(
|
||||||
WindowOptions {
|
WindowOptions {
|
||||||
|
|
|
@ -1345,7 +1345,7 @@ impl BufferStore {
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::BufferSaved> {
|
) -> Result<proto::BufferSaved> {
|
||||||
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
|
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
|
||||||
let (buffer, project_id) = this.read_with(&mut cx, |this, _| {
|
let (buffer, project_id) = this.read_with(&cx, |this, _| {
|
||||||
anyhow::Ok((
|
anyhow::Ok((
|
||||||
this.get_existing(buffer_id)?,
|
this.get_existing(buffer_id)?,
|
||||||
this.downstream_client
|
this.downstream_client
|
||||||
|
@ -1359,7 +1359,7 @@ impl BufferStore {
|
||||||
buffer.wait_for_version(deserialize_version(&envelope.payload.version))
|
buffer.wait_for_version(deserialize_version(&envelope.payload.version))
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
let buffer_id = buffer.read_with(&mut cx, |buffer, _| buffer.remote_id())?;
|
let buffer_id = buffer.read_with(&cx, |buffer, _| buffer.remote_id())?;
|
||||||
|
|
||||||
if let Some(new_path) = envelope.payload.new_path {
|
if let Some(new_path) = envelope.payload.new_path {
|
||||||
let new_path = ProjectPath::from_proto(new_path);
|
let new_path = ProjectPath::from_proto(new_path);
|
||||||
|
@ -1372,7 +1372,7 @@ impl BufferStore {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.read_with(&mut cx, |buffer, _| proto::BufferSaved {
|
buffer.read_with(&cx, |buffer, _| proto::BufferSaved {
|
||||||
project_id,
|
project_id,
|
||||||
buffer_id: buffer_id.into(),
|
buffer_id: buffer_id.into(),
|
||||||
version: serialize_version(buffer.saved_version()),
|
version: serialize_version(buffer.saved_version()),
|
||||||
|
|
|
@ -267,7 +267,7 @@ impl BreakpointStore {
|
||||||
message: TypedEnvelope<proto::ToggleBreakpoint>,
|
message: TypedEnvelope<proto::ToggleBreakpoint>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::Ack> {
|
) -> Result<proto::Ack> {
|
||||||
let breakpoints = this.read_with(&mut cx, |this, _| this.breakpoint_store())?;
|
let breakpoints = this.read_with(&cx, |this, _| this.breakpoint_store())?;
|
||||||
let path = this
|
let path = this
|
||||||
.update(&mut cx, |this, cx| {
|
.update(&mut cx, |this, cx| {
|
||||||
this.project_path_for_absolute_path(message.payload.path.as_ref(), cx)
|
this.project_path_for_absolute_path(message.payload.path.as_ref(), cx)
|
||||||
|
|
|
@ -332,9 +332,9 @@ impl LspCommand for PrepareRename {
|
||||||
_: Entity<LspStore>,
|
_: Entity<LspStore>,
|
||||||
buffer: Entity<Buffer>,
|
buffer: Entity<Buffer>,
|
||||||
_: LanguageServerId,
|
_: LanguageServerId,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> Result<PrepareRenameResponse> {
|
) -> Result<PrepareRenameResponse> {
|
||||||
buffer.read_with(&mut cx, |buffer, _| match message {
|
buffer.read_with(&cx, |buffer, _| match message {
|
||||||
Some(lsp::PrepareRenameResponse::Range(range))
|
Some(lsp::PrepareRenameResponse::Range(range))
|
||||||
| Some(lsp::PrepareRenameResponse::RangeWithPlaceholder { range, .. }) => {
|
| Some(lsp::PrepareRenameResponse::RangeWithPlaceholder { range, .. }) => {
|
||||||
let Range { start, end } = range_from_lsp(range);
|
let Range { start, end } = range_from_lsp(range);
|
||||||
|
@ -386,7 +386,7 @@ impl LspCommand for PrepareRename {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ impl LspCommand for PerformRename {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
new_name: message.new_name,
|
new_name: message.new_name,
|
||||||
push_to_history: false,
|
push_to_history: false,
|
||||||
})
|
})
|
||||||
|
@ -658,7 +658,7 @@ impl LspCommand for GetDefinitions {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,7 +761,7 @@ impl LspCommand for GetDeclarations {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,7 +863,7 @@ impl LspCommand for GetImplementations {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ impl LspCommand for GetTypeDefinitions {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1330,7 +1330,7 @@ impl LspCommand for GetReferences {
|
||||||
|
|
||||||
target_buffer_handle
|
target_buffer_handle
|
||||||
.clone()
|
.clone()
|
||||||
.read_with(&mut cx, |target_buffer, _| {
|
.read_with(&cx, |target_buffer, _| {
|
||||||
let target_start = target_buffer
|
let target_start = target_buffer
|
||||||
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
|
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
|
||||||
let target_end = target_buffer
|
let target_end = target_buffer
|
||||||
|
@ -1374,7 +1374,7 @@ impl LspCommand for GetReferences {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1484,9 +1484,9 @@ impl LspCommand for GetDocumentHighlights {
|
||||||
_: Entity<LspStore>,
|
_: Entity<LspStore>,
|
||||||
buffer: Entity<Buffer>,
|
buffer: Entity<Buffer>,
|
||||||
_: LanguageServerId,
|
_: LanguageServerId,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> Result<Vec<DocumentHighlight>> {
|
) -> Result<Vec<DocumentHighlight>> {
|
||||||
buffer.read_with(&mut cx, |buffer, _| {
|
buffer.read_with(&cx, |buffer, _| {
|
||||||
let mut lsp_highlights = lsp_highlights.unwrap_or_default();
|
let mut lsp_highlights = lsp_highlights.unwrap_or_default();
|
||||||
lsp_highlights.sort_unstable_by_key(|h| (h.range.start, Reverse(h.range.end)));
|
lsp_highlights.sort_unstable_by_key(|h| (h.range.start, Reverse(h.range.end)));
|
||||||
lsp_highlights
|
lsp_highlights
|
||||||
|
@ -1534,7 +1534,7 @@ impl LspCommand for GetDocumentHighlights {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1865,7 +1865,7 @@ impl LspCommand for GetSignatureHelp {
|
||||||
})?
|
})?
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("waiting for version for buffer {}", buffer.entity_id()))?;
|
.with_context(|| format!("waiting for version for buffer {}", buffer.entity_id()))?;
|
||||||
let buffer_snapshot = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot())?;
|
let buffer_snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot())?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: payload
|
position: payload
|
||||||
.position
|
.position
|
||||||
|
@ -1947,13 +1947,13 @@ impl LspCommand for GetHover {
|
||||||
_: Entity<LspStore>,
|
_: Entity<LspStore>,
|
||||||
buffer: Entity<Buffer>,
|
buffer: Entity<Buffer>,
|
||||||
_: LanguageServerId,
|
_: LanguageServerId,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> Result<Self::Response> {
|
) -> Result<Self::Response> {
|
||||||
let Some(hover) = message else {
|
let Some(hover) = message else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
let (language, range) = buffer.read_with(&mut cx, |buffer, _| {
|
let (language, range) = buffer.read_with(&cx, |buffer, _| {
|
||||||
(
|
(
|
||||||
buffer.language().cloned(),
|
buffer.language().cloned(),
|
||||||
hover.range.map(|range| {
|
hover.range.map(|range| {
|
||||||
|
@ -2039,7 +2039,7 @@ impl LspCommand for GetHover {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2113,7 +2113,7 @@ impl LspCommand for GetHover {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
let language = buffer.read_with(&mut cx, |buffer, _| buffer.language().cloned())?;
|
let language = buffer.read_with(&cx, |buffer, _| buffer.language().cloned())?;
|
||||||
let range = if let (Some(start), Some(end)) = (message.start, message.end) {
|
let range = if let (Some(start), Some(end)) = (message.start, message.end) {
|
||||||
language::proto::deserialize_anchor(start)
|
language::proto::deserialize_anchor(start)
|
||||||
.and_then(|start| language::proto::deserialize_anchor(end).map(|end| start..end))
|
.and_then(|start| language::proto::deserialize_anchor(end).map(|end| start..end))
|
||||||
|
@ -2208,7 +2208,7 @@ impl LspCommand for GetCompletions {
|
||||||
let unfiltered_completions_count = completions.len();
|
let unfiltered_completions_count = completions.len();
|
||||||
|
|
||||||
let language_server_adapter = lsp_store
|
let language_server_adapter = lsp_store
|
||||||
.read_with(&mut cx, |lsp_store, _| {
|
.read_with(&cx, |lsp_store, _| {
|
||||||
lsp_store.language_server_adapter_for_id(server_id)
|
lsp_store.language_server_adapter_for_id(server_id)
|
||||||
})?
|
})?
|
||||||
.with_context(|| format!("no language server with id {server_id}"))?;
|
.with_context(|| format!("no language server with id {server_id}"))?;
|
||||||
|
@ -2394,7 +2394,7 @@ impl LspCommand for GetCompletions {
|
||||||
.position
|
.position
|
||||||
.and_then(language::proto::deserialize_anchor)
|
.and_then(language::proto::deserialize_anchor)
|
||||||
.map(|p| {
|
.map(|p| {
|
||||||
buffer.read_with(&mut cx, |buffer, _| {
|
buffer.read_with(&cx, |buffer, _| {
|
||||||
buffer.clip_point_utf16(Unclipped(p.to_point_utf16(buffer)), Bias::Left)
|
buffer.clip_point_utf16(Unclipped(p.to_point_utf16(buffer)), Bias::Left)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2862,7 +2862,7 @@ impl LspCommand for OnTypeFormatting {
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
trigger: message.trigger.clone(),
|
trigger: message.trigger.clone(),
|
||||||
options,
|
options,
|
||||||
push_to_history: false,
|
push_to_history: false,
|
||||||
|
@ -3474,9 +3474,9 @@ impl LspCommand for GetCodeLens {
|
||||||
lsp_store: Entity<LspStore>,
|
lsp_store: Entity<LspStore>,
|
||||||
buffer: Entity<Buffer>,
|
buffer: Entity<Buffer>,
|
||||||
server_id: LanguageServerId,
|
server_id: LanguageServerId,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> anyhow::Result<Vec<CodeAction>> {
|
) -> anyhow::Result<Vec<CodeAction>> {
|
||||||
let snapshot = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot())?;
|
let snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot())?;
|
||||||
let language_server = cx.update(|cx| {
|
let language_server = cx.update(|cx| {
|
||||||
lsp_store
|
lsp_store
|
||||||
.read(cx)
|
.read(cx)
|
||||||
|
|
|
@ -669,10 +669,10 @@ impl LocalLspStore {
|
||||||
let this = this.clone();
|
let this = this.clone();
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
let this = this.clone();
|
let this = this.clone();
|
||||||
let mut cx = cx.clone();
|
let cx = cx.clone();
|
||||||
async move {
|
async move {
|
||||||
let Some(server) = this
|
let Some(server) =
|
||||||
.read_with(&mut cx, |this, _| this.language_server_for_id(server_id))?
|
this.read_with(&cx, |this, _| this.language_server_for_id(server_id))?
|
||||||
else {
|
else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
@ -8154,7 +8154,7 @@ impl LspStore {
|
||||||
envelope: TypedEnvelope<proto::MultiLspQuery>,
|
envelope: TypedEnvelope<proto::MultiLspQuery>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::MultiLspQueryResponse> {
|
) -> Result<proto::MultiLspQueryResponse> {
|
||||||
let response_from_ssh = lsp_store.read_with(&mut cx, |this, _| {
|
let response_from_ssh = lsp_store.read_with(&cx, |this, _| {
|
||||||
let (upstream_client, project_id) = this.upstream_client()?;
|
let (upstream_client, project_id) = this.upstream_client()?;
|
||||||
let mut payload = envelope.payload.clone();
|
let mut payload = envelope.payload.clone();
|
||||||
payload.project_id = project_id;
|
payload.project_id = project_id;
|
||||||
|
@ -8176,7 +8176,7 @@ impl LspStore {
|
||||||
buffer.wait_for_version(version.clone())
|
buffer.wait_for_version(version.clone())
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
let buffer_version = buffer.read_with(&mut cx, |buffer, _| buffer.version())?;
|
let buffer_version = buffer.read_with(&cx, |buffer, _| buffer.version())?;
|
||||||
match envelope
|
match envelope
|
||||||
.payload
|
.payload
|
||||||
.strategy
|
.strategy
|
||||||
|
@ -8717,7 +8717,7 @@ impl LspStore {
|
||||||
})?
|
})?
|
||||||
.context("worktree not found")?;
|
.context("worktree not found")?;
|
||||||
let (old_abs_path, new_abs_path) = {
|
let (old_abs_path, new_abs_path) = {
|
||||||
let root_path = worktree.read_with(&mut cx, |this, _| this.abs_path())?;
|
let root_path = worktree.read_with(&cx, |this, _| this.abs_path())?;
|
||||||
let new_path = PathBuf::from_proto(envelope.payload.new_path.clone());
|
let new_path = PathBuf::from_proto(envelope.payload.new_path.clone());
|
||||||
(root_path.join(&old_path), root_path.join(&new_path))
|
(root_path.join(&old_path), root_path.join(&new_path))
|
||||||
};
|
};
|
||||||
|
@ -8732,7 +8732,7 @@ impl LspStore {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
let response = Worktree::handle_rename_entry(worktree, envelope.payload, cx.clone()).await;
|
let response = Worktree::handle_rename_entry(worktree, envelope.payload, cx.clone()).await;
|
||||||
this.read_with(&mut cx, |this, _| {
|
this.read_with(&cx, |this, _| {
|
||||||
this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);
|
this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
@ -8966,10 +8966,10 @@ impl LspStore {
|
||||||
async fn handle_lsp_ext_cancel_flycheck(
|
async fn handle_lsp_ext_cancel_flycheck(
|
||||||
lsp_store: Entity<Self>,
|
lsp_store: Entity<Self>,
|
||||||
envelope: TypedEnvelope<proto::LspExtCancelFlycheck>,
|
envelope: TypedEnvelope<proto::LspExtCancelFlycheck>,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> Result<proto::Ack> {
|
) -> Result<proto::Ack> {
|
||||||
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
|
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
|
||||||
lsp_store.read_with(&mut cx, |lsp_store, _| {
|
lsp_store.read_with(&cx, |lsp_store, _| {
|
||||||
if let Some(server) = lsp_store.language_server_for_id(server_id) {
|
if let Some(server) = lsp_store.language_server_for_id(server_id) {
|
||||||
server
|
server
|
||||||
.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())
|
.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())
|
||||||
|
@ -9018,10 +9018,10 @@ impl LspStore {
|
||||||
async fn handle_lsp_ext_clear_flycheck(
|
async fn handle_lsp_ext_clear_flycheck(
|
||||||
lsp_store: Entity<Self>,
|
lsp_store: Entity<Self>,
|
||||||
envelope: TypedEnvelope<proto::LspExtClearFlycheck>,
|
envelope: TypedEnvelope<proto::LspExtClearFlycheck>,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> Result<proto::Ack> {
|
) -> Result<proto::Ack> {
|
||||||
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
|
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
|
||||||
lsp_store.read_with(&mut cx, |lsp_store, _| {
|
lsp_store.read_with(&cx, |lsp_store, _| {
|
||||||
if let Some(server) = lsp_store.language_server_for_id(server_id) {
|
if let Some(server) = lsp_store.language_server_for_id(server_id) {
|
||||||
server
|
server
|
||||||
.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())
|
.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())
|
||||||
|
@ -9789,7 +9789,7 @@ impl LspStore {
|
||||||
let peer_id = envelope.original_sender_id().unwrap_or_default();
|
let peer_id = envelope.original_sender_id().unwrap_or_default();
|
||||||
let symbol = envelope.payload.symbol.context("invalid symbol")?;
|
let symbol = envelope.payload.symbol.context("invalid symbol")?;
|
||||||
let symbol = Self::deserialize_symbol(symbol)?;
|
let symbol = Self::deserialize_symbol(symbol)?;
|
||||||
let symbol = this.read_with(&mut cx, |this, _| {
|
let symbol = this.read_with(&cx, |this, _| {
|
||||||
let signature = this.symbol_signature(&symbol.path);
|
let signature = this.symbol_signature(&symbol.path);
|
||||||
anyhow::ensure!(signature == symbol.signature, "invalid symbol signature");
|
anyhow::ensure!(signature == symbol.signature, "invalid symbol signature");
|
||||||
Ok(symbol)
|
Ok(symbol)
|
||||||
|
|
|
@ -115,14 +115,14 @@ impl LspCommand for ExpandMacro {
|
||||||
message: Self::ProtoRequest,
|
message: Self::ProtoRequest,
|
||||||
_: Entity<LspStore>,
|
_: Entity<LspStore>,
|
||||||
buffer: Entity<Buffer>,
|
buffer: Entity<Buffer>,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> anyhow::Result<Self> {
|
) -> anyhow::Result<Self> {
|
||||||
let position = message
|
let position = message
|
||||||
.position
|
.position
|
||||||
.and_then(deserialize_anchor)
|
.and_then(deserialize_anchor)
|
||||||
.context("invalid position")?;
|
.context("invalid position")?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,14 +249,14 @@ impl LspCommand for OpenDocs {
|
||||||
message: Self::ProtoRequest,
|
message: Self::ProtoRequest,
|
||||||
_: Entity<LspStore>,
|
_: Entity<LspStore>,
|
||||||
buffer: Entity<Buffer>,
|
buffer: Entity<Buffer>,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> anyhow::Result<Self> {
|
) -> anyhow::Result<Self> {
|
||||||
let position = message
|
let position = message
|
||||||
.position
|
.position
|
||||||
.and_then(deserialize_anchor)
|
.and_then(deserialize_anchor)
|
||||||
.context("invalid position")?;
|
.context("invalid position")?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,14 +462,14 @@ impl LspCommand for GoToParentModule {
|
||||||
request: Self::ProtoRequest,
|
request: Self::ProtoRequest,
|
||||||
_: Entity<LspStore>,
|
_: Entity<LspStore>,
|
||||||
buffer: Entity<Buffer>,
|
buffer: Entity<Buffer>,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> anyhow::Result<Self> {
|
) -> anyhow::Result<Self> {
|
||||||
let position = request
|
let position = request
|
||||||
.position
|
.position
|
||||||
.and_then(deserialize_anchor)
|
.and_then(deserialize_anchor)
|
||||||
.context("bad request with bad position")?;
|
.context("bad request with bad position")?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1613,25 +1613,23 @@ impl Project {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|s| match s {
|
.map(|s| match s {
|
||||||
EntitySubscription::BufferStore(subscription) => {
|
EntitySubscription::BufferStore(subscription) => {
|
||||||
subscription.set_entity(&buffer_store, &mut cx)
|
subscription.set_entity(&buffer_store, &cx)
|
||||||
}
|
}
|
||||||
EntitySubscription::WorktreeStore(subscription) => {
|
EntitySubscription::WorktreeStore(subscription) => {
|
||||||
subscription.set_entity(&worktree_store, &mut cx)
|
subscription.set_entity(&worktree_store, &cx)
|
||||||
}
|
}
|
||||||
EntitySubscription::GitStore(subscription) => {
|
EntitySubscription::GitStore(subscription) => {
|
||||||
subscription.set_entity(&git_store, &mut cx)
|
subscription.set_entity(&git_store, &cx)
|
||||||
}
|
}
|
||||||
EntitySubscription::SettingsObserver(subscription) => {
|
EntitySubscription::SettingsObserver(subscription) => {
|
||||||
subscription.set_entity(&settings_observer, &mut cx)
|
subscription.set_entity(&settings_observer, &cx)
|
||||||
}
|
|
||||||
EntitySubscription::Project(subscription) => {
|
|
||||||
subscription.set_entity(&this, &mut cx)
|
|
||||||
}
|
}
|
||||||
|
EntitySubscription::Project(subscription) => subscription.set_entity(&this, &cx),
|
||||||
EntitySubscription::LspStore(subscription) => {
|
EntitySubscription::LspStore(subscription) => {
|
||||||
subscription.set_entity(&lsp_store, &mut cx)
|
subscription.set_entity(&lsp_store, &cx)
|
||||||
}
|
}
|
||||||
EntitySubscription::DapStore(subscription) => {
|
EntitySubscription::DapStore(subscription) => {
|
||||||
subscription.set_entity(&dap_store, &mut cx)
|
subscription.set_entity(&dap_store, &cx)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
@ -2226,28 +2224,28 @@ impl Project {
|
||||||
self.client_subscriptions.extend([
|
self.client_subscriptions.extend([
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)?
|
.subscribe_to_entity(project_id)?
|
||||||
.set_entity(&cx.entity(), &mut cx.to_async()),
|
.set_entity(&cx.entity(), &cx.to_async()),
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)?
|
.subscribe_to_entity(project_id)?
|
||||||
.set_entity(&self.worktree_store, &mut cx.to_async()),
|
.set_entity(&self.worktree_store, &cx.to_async()),
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)?
|
.subscribe_to_entity(project_id)?
|
||||||
.set_entity(&self.buffer_store, &mut cx.to_async()),
|
.set_entity(&self.buffer_store, &cx.to_async()),
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)?
|
.subscribe_to_entity(project_id)?
|
||||||
.set_entity(&self.lsp_store, &mut cx.to_async()),
|
.set_entity(&self.lsp_store, &cx.to_async()),
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)?
|
.subscribe_to_entity(project_id)?
|
||||||
.set_entity(&self.settings_observer, &mut cx.to_async()),
|
.set_entity(&self.settings_observer, &cx.to_async()),
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)?
|
.subscribe_to_entity(project_id)?
|
||||||
.set_entity(&self.dap_store, &mut cx.to_async()),
|
.set_entity(&self.dap_store, &cx.to_async()),
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)?
|
.subscribe_to_entity(project_id)?
|
||||||
.set_entity(&self.breakpoint_store, &mut cx.to_async()),
|
.set_entity(&self.breakpoint_store, &cx.to_async()),
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)?
|
.subscribe_to_entity(project_id)?
|
||||||
.set_entity(&self.git_store, &mut cx.to_async()),
|
.set_entity(&self.git_store, &cx.to_async()),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||||
|
|
|
@ -202,7 +202,7 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(search_history.current(&cursor), Some("TypeScript"));
|
assert_eq!(search_history.current(&cursor), Some("TypeScript"));
|
||||||
cursor.reset();
|
cursor.reset();
|
||||||
assert_eq!(search_history.current(&mut cursor), None);
|
assert_eq!(search_history.current(&cursor), None);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
search_history.previous(&mut cursor),
|
search_history.previous(&mut cursor),
|
||||||
Some("TypeScript"),
|
Some("TypeScript"),
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl TaskStore {
|
||||||
.payload
|
.payload
|
||||||
.location
|
.location
|
||||||
.context("no location given for task context handling")?;
|
.context("no location given for task context handling")?;
|
||||||
let (buffer_store, is_remote) = store.read_with(&mut cx, |store, _| {
|
let (buffer_store, is_remote) = store.read_with(&cx, |store, _| {
|
||||||
Ok(match store {
|
Ok(match store {
|
||||||
TaskStore::Functional(state) => (
|
TaskStore::Functional(state) => (
|
||||||
state.buffer_store.clone(),
|
state.buffer_store.clone(),
|
||||||
|
|
|
@ -372,7 +372,7 @@ impl HeadlessProject {
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::AddWorktreeResponse> {
|
) -> Result<proto::AddWorktreeResponse> {
|
||||||
use client::ErrorCodeExt;
|
use client::ErrorCodeExt;
|
||||||
let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;
|
let fs = this.read_with(&cx, |this, _| this.fs.clone())?;
|
||||||
let path = PathBuf::from_proto(shellexpand::tilde(&message.payload.path).to_string());
|
let path = PathBuf::from_proto(shellexpand::tilde(&message.payload.path).to_string());
|
||||||
|
|
||||||
let canonicalized = match fs.canonicalize(&path).await {
|
let canonicalized = match fs.canonicalize(&path).await {
|
||||||
|
@ -396,7 +396,7 @@ impl HeadlessProject {
|
||||||
};
|
};
|
||||||
|
|
||||||
let worktree = this
|
let worktree = this
|
||||||
.read_with(&mut cx.clone(), |this, _| {
|
.read_with(&cx.clone(), |this, _| {
|
||||||
Worktree::local(
|
Worktree::local(
|
||||||
Arc::from(canonicalized.as_path()),
|
Arc::from(canonicalized.as_path()),
|
||||||
message.payload.visible,
|
message.payload.visible,
|
||||||
|
@ -407,7 +407,7 @@ impl HeadlessProject {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let response = this.read_with(&mut cx, |_, cx| {
|
let response = this.read_with(&cx, |_, cx| {
|
||||||
let worktree = worktree.read(cx);
|
let worktree = worktree.read(cx);
|
||||||
proto::AddWorktreeResponse {
|
proto::AddWorktreeResponse {
|
||||||
worktree_id: worktree.id().to_proto(),
|
worktree_id: worktree.id().to_proto(),
|
||||||
|
@ -586,7 +586,7 @@ impl HeadlessProject {
|
||||||
let buffer_store = this.read_with(&cx, |this, _| this.buffer_store.clone())?;
|
let buffer_store = this.read_with(&cx, |this, _| this.buffer_store.clone())?;
|
||||||
|
|
||||||
while let Ok(buffer) = results.recv().await {
|
while let Ok(buffer) = results.recv().await {
|
||||||
let buffer_id = buffer.read_with(&mut cx, |this, _| this.remote_id())?;
|
let buffer_id = buffer.read_with(&cx, |this, _| this.remote_id())?;
|
||||||
response.buffer_ids.push(buffer_id.to_proto());
|
response.buffer_ids.push(buffer_id.to_proto());
|
||||||
buffer_store
|
buffer_store
|
||||||
.update(&mut cx, |buffer_store, cx| {
|
.update(&mut cx, |buffer_store, cx| {
|
||||||
|
|
|
@ -622,7 +622,7 @@ pub fn execute_proxy(identifier: String, is_reconnecting: bool) -> Result<()> {
|
||||||
Err(anyhow!(error))?;
|
Err(anyhow!(error))?;
|
||||||
}
|
}
|
||||||
n => {
|
n => {
|
||||||
stderr.write_all(&mut stderr_buffer[..n]).await?;
|
stderr.write_all(&stderr_buffer[..n]).await?;
|
||||||
stderr.flush().await?;
|
stderr.flush().await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1340,7 +1340,7 @@ impl BufferSearchBar {
|
||||||
if self.query(cx).is_empty()
|
if self.query(cx).is_empty()
|
||||||
&& let Some(new_query) = self
|
&& let Some(new_query) = self
|
||||||
.search_history
|
.search_history
|
||||||
.current(&mut self.search_history_cursor)
|
.current(&self.search_history_cursor)
|
||||||
.map(str::to_string)
|
.map(str::to_string)
|
||||||
{
|
{
|
||||||
drop(self.search(&new_query, Some(self.search_options), window, cx));
|
drop(self.search(&new_query, Some(self.search_options), window, cx));
|
||||||
|
|
|
@ -4111,7 +4111,7 @@ pub mod tests {
|
||||||
});
|
});
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
let project_search_view = pane
|
let project_search_view = pane
|
||||||
.read_with(&mut cx, |pane, _| {
|
.read_with(&cx, |pane, _| {
|
||||||
pane.active_item()
|
pane.active_item()
|
||||||
.and_then(|item| item.downcast::<ProjectSearchView>())
|
.and_then(|item| item.downcast::<ProjectSearchView>())
|
||||||
})
|
})
|
||||||
|
|
|
@ -811,7 +811,7 @@ mod tests {
|
||||||
pub fn expect_keystrokes(&mut self, expected: &[&str]) -> &mut Self {
|
pub fn expect_keystrokes(&mut self, expected: &[&str]) -> &mut Self {
|
||||||
let actual = self
|
let actual = self
|
||||||
.input
|
.input
|
||||||
.read_with(&mut self.cx, |input, _| input.keystrokes.clone());
|
.read_with(&self.cx, |input, _| input.keystrokes.clone());
|
||||||
Self::expect_keystrokes_equal(&actual, expected);
|
Self::expect_keystrokes_equal(&actual, expected);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -820,7 +820,7 @@ mod tests {
|
||||||
pub fn expect_close_keystrokes(&mut self, expected: &[&str]) -> &mut Self {
|
pub fn expect_close_keystrokes(&mut self, expected: &[&str]) -> &mut Self {
|
||||||
let actual = self
|
let actual = self
|
||||||
.input
|
.input
|
||||||
.read_with(&mut self.cx, |input, _| input.close_keystrokes.clone())
|
.read_with(&self.cx, |input, _| input.close_keystrokes.clone())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
Self::expect_keystrokes_equal(&actual, expected);
|
Self::expect_keystrokes_equal(&actual, expected);
|
||||||
self
|
self
|
||||||
|
|
|
@ -69,7 +69,7 @@ async fn process_updates(
|
||||||
entries: Vec<PathBuf>,
|
entries: Vec<PathBuf>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;
|
let fs = this.read_with(&cx, |this, _| this.fs.clone())?;
|
||||||
for entry_path in entries {
|
for entry_path in entries {
|
||||||
if !entry_path
|
if !entry_path
|
||||||
.extension()
|
.extension()
|
||||||
|
@ -118,9 +118,9 @@ async fn process_updates(
|
||||||
async fn initial_scan(
|
async fn initial_scan(
|
||||||
this: WeakEntity<SnippetProvider>,
|
this: WeakEntity<SnippetProvider>,
|
||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
mut cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;
|
let fs = this.read_with(&cx, |this, _| this.fs.clone())?;
|
||||||
let entries = fs.read_dir(&path).await;
|
let entries = fs.read_dir(&path).await;
|
||||||
if let Ok(entries) = entries {
|
if let Ok(entries) = entries {
|
||||||
let entries = entries
|
let entries = entries
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue