mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 20:32:22 +03:00
chore: Fix some violations of 'needless_pass_by_ref_mut' lint (#18795)
While this lint is allow-by-default, it seems pretty useful to get rid of mutable borrows when they're not needed. Closes #ISSUE Release Notes: - N/A
This commit is contained in:
parent
59f0f4ac42
commit
03c84466c2
@ -1 +1,2 @@
|
|||||||
allow-private-module-inception = true
|
allow-private-module-inception = true
|
||||||
|
avoid-breaking-exported-api = false
|
||||||
|
@ -549,7 +549,7 @@ impl Context {
|
|||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let buffer = cx.new_model(|_cx| {
|
let buffer = cx.new_model(|_cx| {
|
||||||
let mut buffer = Buffer::remote(
|
let buffer = Buffer::remote(
|
||||||
language::BufferId::new(1).unwrap(),
|
language::BufferId::new(1).unwrap(),
|
||||||
replica_id,
|
replica_id,
|
||||||
capability,
|
capability,
|
||||||
|
@ -394,7 +394,7 @@ pub struct PendingEntitySubscription<T: 'static> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static> PendingEntitySubscription<T> {
|
impl<T: 'static> PendingEntitySubscription<T> {
|
||||||
pub fn set_model(mut self, model: &Model<T>, cx: &mut AsyncAppContext) -> Subscription {
|
pub fn set_model(mut self, model: &Model<T>, cx: &AsyncAppContext) -> Subscription {
|
||||||
self.consumed = true;
|
self.consumed = true;
|
||||||
let mut handlers = self.client.handler_set.lock();
|
let mut handlers = self.client.handler_set.lock();
|
||||||
let id = (TypeId::of::<T>(), self.remote_id);
|
let id = (TypeId::of::<T>(), self.remote_id);
|
||||||
|
@ -288,7 +288,7 @@ impl Telemetry {
|
|||||||
system_id: Option<String>,
|
system_id: Option<String>,
|
||||||
installation_id: Option<String>,
|
installation_id: Option<String>,
|
||||||
session_id: String,
|
session_id: String,
|
||||||
cx: &mut AppContext,
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let mut state = self.state.lock();
|
let mut state = self.state.lock();
|
||||||
state.system_id = system_id.map(|id| id.into());
|
state.system_id = system_id.map(|id| id.into());
|
||||||
|
@ -138,7 +138,7 @@ enum UpdateContacts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl UserStore {
|
impl UserStore {
|
||||||
pub fn new(client: Arc<Client>, cx: &mut ModelContext<Self>) -> Self {
|
pub fn new(client: Arc<Client>, cx: &ModelContext<Self>) -> Self {
|
||||||
let (mut current_user_tx, current_user_rx) = watch::channel();
|
let (mut current_user_tx, current_user_rx) = watch::channel();
|
||||||
let (update_contacts_tx, mut update_contacts_rx) = mpsc::unbounded();
|
let (update_contacts_tx, mut update_contacts_rx) = mpsc::unbounded();
|
||||||
let rpc_subscriptions = vec![
|
let rpc_subscriptions = vec![
|
||||||
@ -310,7 +310,7 @@ impl UserStore {
|
|||||||
fn update_contacts(
|
fn update_contacts(
|
||||||
&mut self,
|
&mut self,
|
||||||
message: UpdateContacts,
|
message: UpdateContacts,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
match message {
|
match message {
|
||||||
UpdateContacts::Wait(barrier) => {
|
UpdateContacts::Wait(barrier) => {
|
||||||
@ -525,9 +525,9 @@ impl UserStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn dismiss_contact_request(
|
pub fn dismiss_contact_request(
|
||||||
&mut self,
|
&self,
|
||||||
requester_id: u64,
|
requester_id: u64,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
let client = self.client.upgrade();
|
let client = self.client.upgrade();
|
||||||
cx.spawn(move |_, _| async move {
|
cx.spawn(move |_, _| async move {
|
||||||
@ -573,7 +573,7 @@ impl UserStore {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_contacts(&mut self) -> impl Future<Output = ()> {
|
pub fn clear_contacts(&self) -> impl Future<Output = ()> {
|
||||||
let (tx, mut rx) = postage::barrier::channel();
|
let (tx, mut rx) = postage::barrier::channel();
|
||||||
self.update_contacts_tx
|
self.update_contacts_tx
|
||||||
.unbounded_send(UpdateContacts::Clear(tx))
|
.unbounded_send(UpdateContacts::Clear(tx))
|
||||||
@ -583,7 +583,7 @@ impl UserStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn contact_updates_done(&mut self) -> impl Future<Output = ()> {
|
pub fn contact_updates_done(&self) -> impl Future<Output = ()> {
|
||||||
let (tx, mut rx) = postage::barrier::channel();
|
let (tx, mut rx) = postage::barrier::channel();
|
||||||
self.update_contacts_tx
|
self.update_contacts_tx
|
||||||
.unbounded_send(UpdateContacts::Wait(tx))
|
.unbounded_send(UpdateContacts::Wait(tx))
|
||||||
@ -594,9 +594,9 @@ impl UserStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_users(
|
pub fn get_users(
|
||||||
&mut self,
|
&self,
|
||||||
user_ids: Vec<u64>,
|
user_ids: Vec<u64>,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Task<Result<Vec<Arc<User>>>> {
|
) -> Task<Result<Vec<Arc<User>>>> {
|
||||||
let mut user_ids_to_fetch = user_ids.clone();
|
let mut user_ids_to_fetch = user_ids.clone();
|
||||||
user_ids_to_fetch.retain(|id| !self.users.contains_key(id));
|
user_ids_to_fetch.retain(|id| !self.users.contains_key(id));
|
||||||
@ -629,9 +629,9 @@ impl UserStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn fuzzy_search_users(
|
pub fn fuzzy_search_users(
|
||||||
&mut self,
|
&self,
|
||||||
query: String,
|
query: String,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Task<Result<Vec<Arc<User>>>> {
|
) -> Task<Result<Vec<Arc<User>>>> {
|
||||||
self.load_users(proto::FuzzySearchUsers { query }, cx)
|
self.load_users(proto::FuzzySearchUsers { query }, cx)
|
||||||
}
|
}
|
||||||
@ -640,11 +640,7 @@ impl UserStore {
|
|||||||
self.users.get(&user_id).cloned()
|
self.users.get(&user_id).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_user_optimistic(
|
pub fn get_user_optimistic(&self, user_id: u64, cx: &ModelContext<Self>) -> Option<Arc<User>> {
|
||||||
&mut self,
|
|
||||||
user_id: u64,
|
|
||||||
cx: &mut ModelContext<Self>,
|
|
||||||
) -> Option<Arc<User>> {
|
|
||||||
if let Some(user) = self.users.get(&user_id).cloned() {
|
if let Some(user) = self.users.get(&user_id).cloned() {
|
||||||
return Some(user);
|
return Some(user);
|
||||||
}
|
}
|
||||||
@ -653,11 +649,7 @@ impl UserStore {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_user(
|
pub fn get_user(&self, user_id: u64, cx: &ModelContext<Self>) -> Task<Result<Arc<User>>> {
|
||||||
&mut self,
|
|
||||||
user_id: u64,
|
|
||||||
cx: &mut ModelContext<Self>,
|
|
||||||
) -> Task<Result<Arc<User>>> {
|
|
||||||
if let Some(user) = self.users.get(&user_id).cloned() {
|
if let Some(user) = self.users.get(&user_id).cloned() {
|
||||||
return Task::ready(Ok(user));
|
return Task::ready(Ok(user));
|
||||||
}
|
}
|
||||||
@ -697,7 +689,7 @@ impl UserStore {
|
|||||||
.map(|accepted_tos_at| accepted_tos_at.is_some())
|
.map(|accepted_tos_at| accepted_tos_at.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn accept_terms_of_service(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
|
pub fn accept_terms_of_service(&self, cx: &ModelContext<Self>) -> Task<Result<()>> {
|
||||||
if self.current_user().is_none() {
|
if self.current_user().is_none() {
|
||||||
return Task::ready(Err(anyhow!("no current user")));
|
return Task::ready(Err(anyhow!("no current user")));
|
||||||
};
|
};
|
||||||
@ -726,9 +718,9 @@ impl UserStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn load_users(
|
fn load_users(
|
||||||
&mut self,
|
&self,
|
||||||
request: impl RequestMessage<Response = UsersResponse>,
|
request: impl RequestMessage<Response = UsersResponse>,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Task<Result<Vec<Arc<User>>>> {
|
) -> Task<Result<Vec<Arc<User>>>> {
|
||||||
let client = self.client.clone();
|
let client = self.client.clone();
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
|
@ -188,7 +188,7 @@ macro_rules! define_connection {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_and_log<F>(cx: &mut AppContext, db_write: impl FnOnce() -> F + Send + 'static)
|
pub fn write_and_log<F>(cx: &AppContext, db_write: impl FnOnce() -> F + Send + 'static)
|
||||||
where
|
where
|
||||||
F: Future<Output = anyhow::Result<()>> + Send,
|
F: Future<Output = anyhow::Result<()>> + Send,
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ use gpui::AppContext;
|
|||||||
pub use crate::providers::*;
|
pub use crate::providers::*;
|
||||||
|
|
||||||
/// Initializes the Git hosting providers.
|
/// Initializes the Git hosting providers.
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &AppContext) {
|
||||||
let provider_registry = GitHostingProviderRegistry::global(cx);
|
let provider_registry = GitHostingProviderRegistry::global(cx);
|
||||||
|
|
||||||
// The providers are stored in a `BTreeMap`, so insertion order matters.
|
// The providers are stored in a `BTreeMap`, so insertion order matters.
|
||||||
|
@ -348,7 +348,7 @@ impl AppContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gracefully quit the application via the platform's standard routine.
|
/// Gracefully quit the application via the platform's standard routine.
|
||||||
pub fn quit(&mut self) {
|
pub fn quit(&self) {
|
||||||
self.platform.quit();
|
self.platform.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1004,11 +1004,7 @@ impl AppContext {
|
|||||||
self.globals_by_type.insert(global_type, lease.global);
|
self.globals_by_type.insert(global_type, lease.global);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn new_view_observer(
|
pub(crate) fn new_view_observer(&self, key: TypeId, value: NewViewListener) -> Subscription {
|
||||||
&mut self,
|
|
||||||
key: TypeId,
|
|
||||||
value: NewViewListener,
|
|
||||||
) -> Subscription {
|
|
||||||
let (subscription, activate) = self.new_view_observers.insert(key, value);
|
let (subscription, activate) = self.new_view_observers.insert(key, value);
|
||||||
activate();
|
activate();
|
||||||
subscription
|
subscription
|
||||||
@ -1016,7 +1012,7 @@ impl AppContext {
|
|||||||
/// Arrange for the given function to be invoked whenever a view of the specified type is created.
|
/// Arrange for the given function to be invoked whenever a view of the specified type is created.
|
||||||
/// The function will be passed a mutable reference to the view along with an appropriate context.
|
/// The function will be passed a mutable reference to the view along with an appropriate context.
|
||||||
pub fn observe_new_views<V: 'static>(
|
pub fn observe_new_views<V: 'static>(
|
||||||
&mut self,
|
&self,
|
||||||
on_new: impl 'static + Fn(&mut V, &mut ViewContext<V>),
|
on_new: impl 'static + Fn(&mut V, &mut ViewContext<V>),
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
self.new_view_observer(
|
self.new_view_observer(
|
||||||
@ -1035,7 +1031,7 @@ impl AppContext {
|
|||||||
/// Observe the release of a model or view. The callback is invoked after the model or view
|
/// Observe the release of a model or view. The callback is invoked after the model or view
|
||||||
/// has no more strong references but before it has been dropped.
|
/// has no more strong references but before it has been dropped.
|
||||||
pub fn observe_release<E, T>(
|
pub fn observe_release<E, T>(
|
||||||
&mut self,
|
&self,
|
||||||
handle: &E,
|
handle: &E,
|
||||||
on_release: impl FnOnce(&mut T, &mut AppContext) + 'static,
|
on_release: impl FnOnce(&mut T, &mut AppContext) + 'static,
|
||||||
) -> Subscription
|
) -> Subscription
|
||||||
@ -1062,7 +1058,7 @@ impl AppContext {
|
|||||||
mut f: impl FnMut(&KeystrokeEvent, &mut WindowContext) + 'static,
|
mut f: impl FnMut(&KeystrokeEvent, &mut WindowContext) + 'static,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
fn inner(
|
fn inner(
|
||||||
keystroke_observers: &mut SubscriberSet<(), KeystrokeObserver>,
|
keystroke_observers: &SubscriberSet<(), KeystrokeObserver>,
|
||||||
handler: KeystrokeObserver,
|
handler: KeystrokeObserver,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
let (subscription, activate) = keystroke_observers.insert((), handler);
|
let (subscription, activate) = keystroke_observers.insert((), handler);
|
||||||
@ -1140,7 +1136,7 @@ impl AppContext {
|
|||||||
/// Register a callback to be invoked when the application is about to quit.
|
/// Register a callback to be invoked when the application is about to quit.
|
||||||
/// It is not possible to cancel the quit event at this point.
|
/// It is not possible to cancel the quit event at this point.
|
||||||
pub fn on_app_quit<Fut>(
|
pub fn on_app_quit<Fut>(
|
||||||
&mut self,
|
&self,
|
||||||
mut on_quit: impl FnMut(&mut AppContext) -> Fut + 'static,
|
mut on_quit: impl FnMut(&mut AppContext) -> Fut + 'static,
|
||||||
) -> Subscription
|
) -> Subscription
|
||||||
where
|
where
|
||||||
@ -1186,7 +1182,7 @@ impl AppContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the menu bar for this application. This will replace any existing menu bar.
|
/// Sets the menu bar for this application. This will replace any existing menu bar.
|
||||||
pub fn set_menus(&mut self, menus: Vec<Menu>) {
|
pub fn set_menus(&self, menus: Vec<Menu>) {
|
||||||
self.platform.set_menus(menus, &self.keymap.borrow());
|
self.platform.set_menus(menus, &self.keymap.borrow());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1196,7 +1192,7 @@ impl AppContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the right click menu for the app icon in the dock
|
/// Sets the right click menu for the app icon in the dock
|
||||||
pub fn set_dock_menu(&mut self, menus: Vec<MenuItem>) {
|
pub fn set_dock_menu(&self, menus: Vec<MenuItem>) {
|
||||||
self.platform.set_dock_menu(menus, &self.keymap.borrow());
|
self.platform.set_dock_menu(menus, &self.keymap.borrow());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1204,7 +1200,7 @@ impl AppContext {
|
|||||||
/// The list is usually shown on the application icon's context menu in the dock,
|
/// The list is usually shown on the application icon's context menu in the dock,
|
||||||
/// and allows to open the recent files via that context menu.
|
/// and allows to open the recent files via that context menu.
|
||||||
/// If the path is already in the list, it will be moved to the bottom of the list.
|
/// If the path is already in the list, it will be moved to the bottom of the list.
|
||||||
pub fn add_recent_document(&mut self, path: &Path) {
|
pub fn add_recent_document(&self, path: &Path) {
|
||||||
self.platform.add_recent_document(path);
|
self.platform.add_recent_document(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ impl Context for AsyncAppContext {
|
|||||||
|
|
||||||
impl AsyncAppContext {
|
impl AsyncAppContext {
|
||||||
/// Schedules all windows in the application to be redrawn.
|
/// Schedules all windows in the application to be redrawn.
|
||||||
pub fn refresh(&mut self) -> Result<()> {
|
pub fn refresh(&self) -> Result<()> {
|
||||||
let app = self
|
let app = self
|
||||||
.app
|
.app
|
||||||
.upgrade()
|
.upgrade()
|
||||||
@ -205,7 +205,7 @@ impl AsyncAppContext {
|
|||||||
/// A convenience method for [AppContext::update_global]
|
/// A convenience method for [AppContext::update_global]
|
||||||
/// for updating the global state of the specified type.
|
/// for updating the global state of the specified type.
|
||||||
pub fn update_global<G: Global, R>(
|
pub fn update_global<G: Global, R>(
|
||||||
&mut self,
|
&self,
|
||||||
update: impl FnOnce(&mut G, &mut AppContext) -> R,
|
update: impl FnOnce(&mut G, &mut AppContext) -> R,
|
||||||
) -> Result<R> {
|
) -> Result<R> {
|
||||||
let app = self
|
let app = self
|
||||||
|
@ -91,7 +91,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||||||
|
|
||||||
/// Register a callback to be invoked when GPUI releases this model.
|
/// Register a callback to be invoked when GPUI releases this model.
|
||||||
pub fn on_release(
|
pub fn on_release(
|
||||||
&mut self,
|
&self,
|
||||||
on_release: impl FnOnce(&mut T, &mut AppContext) + 'static,
|
on_release: impl FnOnce(&mut T, &mut AppContext) + 'static,
|
||||||
) -> Subscription
|
) -> Subscription
|
||||||
where
|
where
|
||||||
@ -110,7 +110,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||||||
|
|
||||||
/// Register a callback to be run on the release of another model or view
|
/// Register a callback to be run on the release of another model or view
|
||||||
pub fn observe_release<T2, E>(
|
pub fn observe_release<T2, E>(
|
||||||
&mut self,
|
&self,
|
||||||
entity: &E,
|
entity: &E,
|
||||||
on_release: impl FnOnce(&mut T, &mut T2, &mut ModelContext<'_, T>) + 'static,
|
on_release: impl FnOnce(&mut T, &mut T2, &mut ModelContext<'_, T>) + 'static,
|
||||||
) -> Subscription
|
) -> Subscription
|
||||||
@ -154,7 +154,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||||||
/// Arrange for the given function to be invoked whenever the application is quit.
|
/// Arrange for the given function to be invoked whenever the application is quit.
|
||||||
/// The future returned from this callback will be polled for up to [crate::SHUTDOWN_TIMEOUT] until the app fully quits.
|
/// The future returned from this callback will be polled for up to [crate::SHUTDOWN_TIMEOUT] until the app fully quits.
|
||||||
pub fn on_app_quit<Fut>(
|
pub fn on_app_quit<Fut>(
|
||||||
&mut self,
|
&self,
|
||||||
mut on_quit: impl FnMut(&mut T, &mut ModelContext<T>) -> Fut + 'static,
|
mut on_quit: impl FnMut(&mut T, &mut ModelContext<T>) -> Fut + 'static,
|
||||||
) -> Subscription
|
) -> Subscription
|
||||||
where
|
where
|
||||||
|
@ -1418,7 +1418,7 @@ impl Interactivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn clamp_scroll_position(
|
fn clamp_scroll_position(
|
||||||
&mut self,
|
&self,
|
||||||
bounds: Bounds<Pixels>,
|
bounds: Bounds<Pixels>,
|
||||||
style: &Style,
|
style: &Style,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
@ -1547,7 +1547,7 @@ impl Interactivity {
|
|||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
fn paint_debug_info(
|
fn paint_debug_info(
|
||||||
&mut self,
|
&self,
|
||||||
global_id: Option<&GlobalElementId>,
|
global_id: Option<&GlobalElementId>,
|
||||||
hitbox: &Hitbox,
|
hitbox: &Hitbox,
|
||||||
style: &Style,
|
style: &Style,
|
||||||
|
@ -252,7 +252,7 @@ impl TextLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&mut self,
|
&self,
|
||||||
text: SharedString,
|
text: SharedString,
|
||||||
runs: Option<Vec<TextRun>>,
|
runs: Option<Vec<TextRun>>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
@ -350,7 +350,7 @@ impl TextLayout {
|
|||||||
layout_id
|
layout_id
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepaint(&mut self, bounds: Bounds<Pixels>, text: &str) {
|
fn prepaint(&self, bounds: Bounds<Pixels>, text: &str) {
|
||||||
let mut element_state = self.lock();
|
let mut element_state = self.lock();
|
||||||
let element_state = element_state
|
let element_state = element_state
|
||||||
.as_mut()
|
.as_mut()
|
||||||
@ -359,7 +359,7 @@ impl TextLayout {
|
|||||||
element_state.bounds = Some(bounds);
|
element_state.bounds = Some(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(&mut self, text: &str, cx: &mut WindowContext) {
|
fn paint(&self, text: &str, cx: &mut WindowContext) {
|
||||||
let element_state = self.lock();
|
let element_state = self.lock();
|
||||||
let element_state = element_state
|
let element_state = element_state
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -115,7 +115,7 @@ impl UniformListScrollHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Scroll the list to the given item index.
|
/// Scroll the list to the given item index.
|
||||||
pub fn scroll_to_item(&mut self, ix: usize) {
|
pub fn scroll_to_item(&self, ix: usize) {
|
||||||
self.0.borrow_mut().deferred_scroll_to_item = Some(ix);
|
self.0.borrow_mut().deferred_scroll_to_item = Some(ix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,11 +706,7 @@ pub struct Bounds<T: Clone + Default + Debug> {
|
|||||||
|
|
||||||
impl Bounds<Pixels> {
|
impl Bounds<Pixels> {
|
||||||
/// Generate a centered bounds for the given display or primary display if none is provided
|
/// Generate a centered bounds for the given display or primary display if none is provided
|
||||||
pub fn centered(
|
pub fn centered(display_id: Option<DisplayId>, size: Size<Pixels>, cx: &AppContext) -> Self {
|
||||||
display_id: Option<DisplayId>,
|
|
||||||
size: Size<Pixels>,
|
|
||||||
cx: &mut AppContext,
|
|
||||||
) -> Self {
|
|
||||||
let display = display_id
|
let display = display_id
|
||||||
.and_then(|id| cx.find_display(id))
|
.and_then(|id| cx.find_display(id))
|
||||||
.or_else(|| cx.primary_display());
|
.or_else(|| cx.primary_display());
|
||||||
@ -730,7 +726,7 @@ impl Bounds<Pixels> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Generate maximized bounds for the given display or primary display if none is provided
|
/// Generate maximized bounds for the given display or primary display if none is provided
|
||||||
pub fn maximized(display_id: Option<DisplayId>, cx: &mut AppContext) -> Self {
|
pub fn maximized(display_id: Option<DisplayId>, cx: &AppContext) -> Self {
|
||||||
let display = display_id
|
let display = display_id
|
||||||
.and_then(|id| cx.find_display(id))
|
.and_then(|id| cx.find_display(id))
|
||||||
.or_else(|| cx.primary_display());
|
.or_else(|| cx.primary_display());
|
||||||
|
@ -219,7 +219,7 @@ impl DispatchTree {
|
|||||||
self.focusable_node_ids.insert(focus_id, node_id);
|
self.focusable_node_ids.insert(focus_id, node_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parent_view_id(&mut self) -> Option<EntityId> {
|
pub fn parent_view_id(&self) -> Option<EntityId> {
|
||||||
self.view_stack.last().copied()
|
self.view_stack.last().copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ impl DispatchTree {
|
|||||||
|
|
||||||
/// Converts the longest prefix of input to a replay event and returns the rest.
|
/// Converts the longest prefix of input to a replay event and returns the rest.
|
||||||
fn replay_prefix(
|
fn replay_prefix(
|
||||||
&mut self,
|
&self,
|
||||||
mut input: SmallVec<[Keystroke; 1]>,
|
mut input: SmallVec<[Keystroke; 1]>,
|
||||||
dispatch_path: &SmallVec<[DispatchNodeId; 32]>,
|
dispatch_path: &SmallVec<[DispatchNodeId; 32]>,
|
||||||
) -> (SmallVec<[Keystroke; 1]>, SmallVec<[Replay; 1]>) {
|
) -> (SmallVec<[Keystroke; 1]>, SmallVec<[Replay; 1]>) {
|
||||||
|
@ -171,7 +171,7 @@ pub enum OsAction {
|
|||||||
Redo,
|
Redo,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn init_app_menus(platform: &dyn Platform, cx: &mut AppContext) {
|
pub(crate) fn init_app_menus(platform: &dyn Platform, cx: &AppContext) {
|
||||||
platform.on_will_open_app_menu(Box::new({
|
platform.on_will_open_app_menu(Box::new({
|
||||||
let cx = cx.to_async();
|
let cx = cx.to_async();
|
||||||
move || {
|
move || {
|
||||||
|
@ -284,11 +284,11 @@ impl MetalRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_transparency(&mut self, _transparent: bool) {
|
pub fn update_transparency(&self, _transparent: bool) {
|
||||||
// todo(mac)?
|
// todo(mac)?
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn destroy(&mut self) {
|
pub fn destroy(&self) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ impl MetalRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rasterize_paths(
|
fn rasterize_paths(
|
||||||
&mut self,
|
&self,
|
||||||
paths: &[Path<ScaledPixels>],
|
paths: &[Path<ScaledPixels>],
|
||||||
instance_buffer: &mut InstanceBuffer,
|
instance_buffer: &mut InstanceBuffer,
|
||||||
instance_offset: &mut usize,
|
instance_offset: &mut usize,
|
||||||
@ -576,7 +576,7 @@ impl MetalRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_shadows(
|
fn draw_shadows(
|
||||||
&mut self,
|
&self,
|
||||||
shadows: &[Shadow],
|
shadows: &[Shadow],
|
||||||
instance_buffer: &mut InstanceBuffer,
|
instance_buffer: &mut InstanceBuffer,
|
||||||
instance_offset: &mut usize,
|
instance_offset: &mut usize,
|
||||||
@ -639,7 +639,7 @@ impl MetalRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_quads(
|
fn draw_quads(
|
||||||
&mut self,
|
&self,
|
||||||
quads: &[Quad],
|
quads: &[Quad],
|
||||||
instance_buffer: &mut InstanceBuffer,
|
instance_buffer: &mut InstanceBuffer,
|
||||||
instance_offset: &mut usize,
|
instance_offset: &mut usize,
|
||||||
@ -698,7 +698,7 @@ impl MetalRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_paths(
|
fn draw_paths(
|
||||||
&mut self,
|
&self,
|
||||||
paths: &[Path<ScaledPixels>],
|
paths: &[Path<ScaledPixels>],
|
||||||
tiles_by_path_id: &HashMap<PathId, AtlasTile>,
|
tiles_by_path_id: &HashMap<PathId, AtlasTile>,
|
||||||
instance_buffer: &mut InstanceBuffer,
|
instance_buffer: &mut InstanceBuffer,
|
||||||
@ -808,7 +808,7 @@ impl MetalRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_underlines(
|
fn draw_underlines(
|
||||||
&mut self,
|
&self,
|
||||||
underlines: &[Underline],
|
underlines: &[Underline],
|
||||||
instance_buffer: &mut InstanceBuffer,
|
instance_buffer: &mut InstanceBuffer,
|
||||||
instance_offset: &mut usize,
|
instance_offset: &mut usize,
|
||||||
@ -871,7 +871,7 @@ impl MetalRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_monochrome_sprites(
|
fn draw_monochrome_sprites(
|
||||||
&mut self,
|
&self,
|
||||||
texture_id: AtlasTextureId,
|
texture_id: AtlasTextureId,
|
||||||
sprites: &[MonochromeSprite],
|
sprites: &[MonochromeSprite],
|
||||||
instance_buffer: &mut InstanceBuffer,
|
instance_buffer: &mut InstanceBuffer,
|
||||||
@ -945,7 +945,7 @@ impl MetalRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_polychrome_sprites(
|
fn draw_polychrome_sprites(
|
||||||
&mut self,
|
&self,
|
||||||
texture_id: AtlasTextureId,
|
texture_id: AtlasTextureId,
|
||||||
sprites: &[PolychromeSprite],
|
sprites: &[PolychromeSprite],
|
||||||
instance_buffer: &mut InstanceBuffer,
|
instance_buffer: &mut InstanceBuffer,
|
||||||
|
@ -1432,7 +1432,7 @@ impl UTType {
|
|||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inner_mut(&mut self) -> *mut Object {
|
fn inner_mut(&self) -> *mut Object {
|
||||||
self.0 as *mut _
|
self.0 as *mut _
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -835,10 +835,7 @@ impl Window {
|
|||||||
prompt: None,
|
prompt: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn new_focus_listener(
|
fn new_focus_listener(&self, value: AnyWindowFocusListener) -> (Subscription, impl FnOnce()) {
|
||||||
&mut self,
|
|
||||||
value: AnyWindowFocusListener,
|
|
||||||
) -> (Subscription, impl FnOnce()) {
|
|
||||||
self.focus_listeners.insert((), value)
|
self.focus_listeners.insert((), value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -929,7 +926,7 @@ impl<'a> WindowContext<'a> {
|
|||||||
|
|
||||||
/// Obtain a new [`FocusHandle`], which allows you to track and manipulate the keyboard focus
|
/// Obtain a new [`FocusHandle`], which allows you to track and manipulate the keyboard focus
|
||||||
/// for elements rendered within this window.
|
/// for elements rendered within this window.
|
||||||
pub fn focus_handle(&mut self) -> FocusHandle {
|
pub fn focus_handle(&self) -> FocusHandle {
|
||||||
FocusHandle::new(&self.window.focus_handles)
|
FocusHandle::new(&self.window.focus_handles)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1127,7 +1124,7 @@ impl<'a> WindowContext<'a> {
|
|||||||
|
|
||||||
/// Register a callback to be invoked when the given Model or View is released.
|
/// Register a callback to be invoked when the given Model or View is released.
|
||||||
pub fn observe_release<E, T>(
|
pub fn observe_release<E, T>(
|
||||||
&mut self,
|
&self,
|
||||||
entity: &E,
|
entity: &E,
|
||||||
mut on_release: impl FnOnce(&mut T, &mut WindowContext) + 'static,
|
mut on_release: impl FnOnce(&mut T, &mut WindowContext) + 'static,
|
||||||
) -> Subscription
|
) -> Subscription
|
||||||
@ -1155,7 +1152,7 @@ impl<'a> WindowContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Schedule the given closure to be run directly after the current frame is rendered.
|
/// Schedule the given closure to be run directly after the current frame is rendered.
|
||||||
pub fn on_next_frame(&mut self, callback: impl FnOnce(&mut WindowContext) + 'static) {
|
pub fn on_next_frame(&self, callback: impl FnOnce(&mut WindowContext) + 'static) {
|
||||||
RefCell::borrow_mut(&self.window.next_frame_callbacks).push(Box::new(callback));
|
RefCell::borrow_mut(&self.window.next_frame_callbacks).push(Box::new(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1165,7 +1162,7 @@ impl<'a> WindowContext<'a> {
|
|||||||
/// It will cause the window to redraw on the next frame, even if no other changes have occurred.
|
/// It will cause the window to redraw on the next frame, even if no other changes have occurred.
|
||||||
///
|
///
|
||||||
/// If called from within a view, it will notify that view on the next frame. Otherwise, it will refresh the entire window.
|
/// If called from within a view, it will notify that view on the next frame. Otherwise, it will refresh the entire window.
|
||||||
pub fn request_animation_frame(&mut self) {
|
pub fn request_animation_frame(&self) {
|
||||||
let parent_id = self.parent_view_id();
|
let parent_id = self.parent_view_id();
|
||||||
self.on_next_frame(move |cx| {
|
self.on_next_frame(move |cx| {
|
||||||
if let Some(parent_id) = parent_id {
|
if let Some(parent_id) = parent_id {
|
||||||
@ -1179,7 +1176,7 @@ impl<'a> WindowContext<'a> {
|
|||||||
/// Spawn the future returned by the given closure on the application thread pool.
|
/// Spawn the future returned by the given closure on the application thread pool.
|
||||||
/// The closure is provided a handle to the current window and an `AsyncWindowContext` for
|
/// The closure is provided a handle to the current window and an `AsyncWindowContext` for
|
||||||
/// use within your future.
|
/// use within your future.
|
||||||
pub fn spawn<Fut, R>(&mut self, f: impl FnOnce(AsyncWindowContext) -> Fut) -> Task<R>
|
pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncWindowContext) -> Fut) -> Task<R>
|
||||||
where
|
where
|
||||||
R: 'static,
|
R: 'static,
|
||||||
Fut: Future<Output = R> + 'static,
|
Fut: Future<Output = R> + 'static,
|
||||||
@ -2865,7 +2862,7 @@ impl<'a> WindowContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the last view id for the current element
|
/// Get the last view id for the current element
|
||||||
pub fn parent_view_id(&mut self) -> Option<EntityId> {
|
pub fn parent_view_id(&self) -> Option<EntityId> {
|
||||||
self.window.next_frame.dispatch_tree.parent_view_id()
|
self.window.next_frame.dispatch_tree.parent_view_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3606,7 +3603,7 @@ impl<'a> WindowContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the IME panel position suggestions for languages like japanese, chinese.
|
/// Updates the IME panel position suggestions for languages like japanese, chinese.
|
||||||
pub fn invalidate_character_coordinates(&mut self) {
|
pub fn invalidate_character_coordinates(&self) {
|
||||||
self.on_next_frame(|cx| {
|
self.on_next_frame(|cx| {
|
||||||
if let Some(mut input_handler) = cx.window.platform_window.take_input_handler() {
|
if let Some(mut input_handler) = cx.window.platform_window.take_input_handler() {
|
||||||
if let Some(bounds) = input_handler.selected_bounds(cx) {
|
if let Some(bounds) = input_handler.selected_bounds(cx) {
|
||||||
@ -3752,7 +3749,7 @@ impl<'a> WindowContext<'a> {
|
|||||||
|
|
||||||
/// Register a callback that can interrupt the closing of the current window based the returned boolean.
|
/// Register a callback that can interrupt the closing of the current window based the returned boolean.
|
||||||
/// If the callback returns false, the window won't be closed.
|
/// If the callback returns false, the window won't be closed.
|
||||||
pub fn on_window_should_close(&mut self, f: impl Fn(&mut WindowContext) -> bool + 'static) {
|
pub fn on_window_should_close(&self, f: impl Fn(&mut WindowContext) -> bool + 'static) {
|
||||||
let mut this = self.to_async();
|
let mut this = self.to_async();
|
||||||
self.window
|
self.window
|
||||||
.platform_window
|
.platform_window
|
||||||
@ -4070,7 +4067,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets a given callback to be run on the next frame.
|
/// Sets a given callback to be run on the next frame.
|
||||||
pub fn on_next_frame(&mut self, f: impl FnOnce(&mut V, &mut ViewContext<V>) + 'static)
|
pub fn on_next_frame(&self, f: impl FnOnce(&mut V, &mut ViewContext<V>) + 'static)
|
||||||
where
|
where
|
||||||
V: 'static,
|
V: 'static,
|
||||||
{
|
{
|
||||||
@ -4162,7 +4159,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
/// The callback receives a handle to the view's window. This handle may be
|
/// The callback receives a handle to the view's window. This handle may be
|
||||||
/// invalid, if the window was closed before the view was released.
|
/// invalid, if the window was closed before the view was released.
|
||||||
pub fn on_release(
|
pub fn on_release(
|
||||||
&mut self,
|
&self,
|
||||||
on_release: impl FnOnce(&mut V, AnyWindowHandle, &mut AppContext) + 'static,
|
on_release: impl FnOnce(&mut V, AnyWindowHandle, &mut AppContext) + 'static,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
let window_handle = self.window.handle;
|
let window_handle = self.window.handle;
|
||||||
@ -4179,7 +4176,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
|
|
||||||
/// Register a callback to be invoked when the given Model or View is released.
|
/// Register a callback to be invoked when the given Model or View is released.
|
||||||
pub fn observe_release<V2, E>(
|
pub fn observe_release<V2, E>(
|
||||||
&mut self,
|
&self,
|
||||||
entity: &E,
|
entity: &E,
|
||||||
mut on_release: impl FnMut(&mut V, &mut V2, &mut ViewContext<'_, V>) + 'static,
|
mut on_release: impl FnMut(&mut V, &mut V2, &mut ViewContext<'_, V>) + 'static,
|
||||||
) -> Subscription
|
) -> Subscription
|
||||||
@ -4212,7 +4209,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
|
|
||||||
/// Register a callback to be invoked when the window is resized.
|
/// Register a callback to be invoked when the window is resized.
|
||||||
pub fn observe_window_bounds(
|
pub fn observe_window_bounds(
|
||||||
&mut self,
|
&self,
|
||||||
mut callback: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
mut callback: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
let view = self.view.downgrade();
|
let view = self.view.downgrade();
|
||||||
@ -4226,7 +4223,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
|
|
||||||
/// Register a callback to be invoked when the window is activated or deactivated.
|
/// Register a callback to be invoked when the window is activated or deactivated.
|
||||||
pub fn observe_window_activation(
|
pub fn observe_window_activation(
|
||||||
&mut self,
|
&self,
|
||||||
mut callback: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
mut callback: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
let view = self.view.downgrade();
|
let view = self.view.downgrade();
|
||||||
@ -4240,7 +4237,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
|
|
||||||
/// Registers a callback to be invoked when the window appearance changes.
|
/// Registers a callback to be invoked when the window appearance changes.
|
||||||
pub fn observe_window_appearance(
|
pub fn observe_window_appearance(
|
||||||
&mut self,
|
&self,
|
||||||
mut callback: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
mut callback: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
let view = self.view.downgrade();
|
let view = self.view.downgrade();
|
||||||
@ -4260,7 +4257,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
mut f: impl FnMut(&mut V, &KeystrokeEvent, &mut ViewContext<V>) + 'static,
|
mut f: impl FnMut(&mut V, &KeystrokeEvent, &mut ViewContext<V>) + 'static,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
fn inner(
|
fn inner(
|
||||||
keystroke_observers: &mut SubscriberSet<(), KeystrokeObserver>,
|
keystroke_observers: &SubscriberSet<(), KeystrokeObserver>,
|
||||||
handler: KeystrokeObserver,
|
handler: KeystrokeObserver,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
let (subscription, activate) = keystroke_observers.insert((), handler);
|
let (subscription, activate) = keystroke_observers.insert((), handler);
|
||||||
@ -4284,7 +4281,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
|
|
||||||
/// Register a callback to be invoked when the window's pending input changes.
|
/// Register a callback to be invoked when the window's pending input changes.
|
||||||
pub fn observe_pending_input(
|
pub fn observe_pending_input(
|
||||||
&mut self,
|
&self,
|
||||||
mut callback: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
mut callback: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
let view = self.view.downgrade();
|
let view = self.view.downgrade();
|
||||||
@ -4372,7 +4369,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
/// and this callback lets you chose a default place to restore the users focus.
|
/// and this callback lets you chose a default place to restore the users focus.
|
||||||
/// Returns a subscription and persists until the subscription is dropped.
|
/// Returns a subscription and persists until the subscription is dropped.
|
||||||
pub fn on_focus_lost(
|
pub fn on_focus_lost(
|
||||||
&mut self,
|
&self,
|
||||||
mut listener: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
mut listener: impl FnMut(&mut V, &mut ViewContext<V>) + 'static,
|
||||||
) -> Subscription {
|
) -> Subscription {
|
||||||
let view = self.view.downgrade();
|
let view = self.view.downgrade();
|
||||||
@ -4418,10 +4415,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||||||
/// The given callback is invoked with a [`WeakView<V>`] to avoid leaking the view for a long-running process.
|
/// The given callback is invoked with a [`WeakView<V>`] to avoid leaking the view for a long-running process.
|
||||||
/// It's also given an [`AsyncWindowContext`], which can be used to access the state of the view across await points.
|
/// It's also given an [`AsyncWindowContext`], which can be used to access the state of the view across await points.
|
||||||
/// The returned future will be polled on the main thread.
|
/// The returned future will be polled on the main thread.
|
||||||
pub fn spawn<Fut, R>(
|
pub fn spawn<Fut, R>(&self, f: impl FnOnce(WeakView<V>, AsyncWindowContext) -> Fut) -> Task<R>
|
||||||
&mut self,
|
|
||||||
f: impl FnOnce(WeakView<V>, AsyncWindowContext) -> Fut,
|
|
||||||
) -> Task<R>
|
|
||||||
where
|
where
|
||||||
R: 'static,
|
R: 'static,
|
||||||
Fut: Future<Output = R> + 'static,
|
Fut: Future<Output = R> + 'static,
|
||||||
|
@ -588,7 +588,7 @@ impl IndentGuide {
|
|||||||
|
|
||||||
impl Buffer {
|
impl Buffer {
|
||||||
/// Create a new buffer with the given base text.
|
/// Create a new buffer with the given base text.
|
||||||
pub fn local<T: Into<String>>(base_text: T, cx: &mut ModelContext<Self>) -> Self {
|
pub fn local<T: Into<String>>(base_text: T, cx: &ModelContext<Self>) -> Self {
|
||||||
Self::build(
|
Self::build(
|
||||||
TextBuffer::new(0, cx.entity_id().as_non_zero_u64().into(), base_text.into()),
|
TextBuffer::new(0, cx.entity_id().as_non_zero_u64().into(), base_text.into()),
|
||||||
None,
|
None,
|
||||||
@ -601,7 +601,7 @@ impl Buffer {
|
|||||||
pub fn local_normalized(
|
pub fn local_normalized(
|
||||||
base_text_normalized: Rope,
|
base_text_normalized: Rope,
|
||||||
line_ending: LineEnding,
|
line_ending: LineEnding,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::build(
|
Self::build(
|
||||||
TextBuffer::new_normalized(
|
TextBuffer::new_normalized(
|
||||||
@ -934,7 +934,7 @@ impl Buffer {
|
|||||||
|
|
||||||
/// Assign a language registry to the buffer. This allows the buffer to retrieve
|
/// Assign a language registry to the buffer. This allows the buffer to retrieve
|
||||||
/// other languages if parts of the buffer are written in different languages.
|
/// other languages if parts of the buffer are written in different languages.
|
||||||
pub fn set_language_registry(&mut self, language_registry: Arc<LanguageRegistry>) {
|
pub fn set_language_registry(&self, language_registry: Arc<LanguageRegistry>) {
|
||||||
self.syntax_map
|
self.syntax_map
|
||||||
.lock()
|
.lock()
|
||||||
.set_language_registry(language_registry);
|
.set_language_registry(language_registry);
|
||||||
@ -967,16 +967,13 @@ impl Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// This method is called to signal that the buffer has been discarded.
|
/// This method is called to signal that the buffer has been discarded.
|
||||||
pub fn discarded(&mut self, cx: &mut ModelContext<Self>) {
|
pub fn discarded(&self, cx: &mut ModelContext<Self>) {
|
||||||
cx.emit(BufferEvent::Discarded);
|
cx.emit(BufferEvent::Discarded);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reloads the contents of the buffer from disk.
|
/// Reloads the contents of the buffer from disk.
|
||||||
pub fn reload(
|
pub fn reload(&mut self, cx: &ModelContext<Self>) -> oneshot::Receiver<Option<Transaction>> {
|
||||||
&mut self,
|
|
||||||
cx: &mut ModelContext<Self>,
|
|
||||||
) -> oneshot::Receiver<Option<Transaction>> {
|
|
||||||
let (tx, rx) = futures::channel::oneshot::channel();
|
let (tx, rx) = futures::channel::oneshot::channel();
|
||||||
let prev_version = self.text.version();
|
let prev_version = self.text.version();
|
||||||
self.reload_task = Some(cx.spawn(|this, mut cx| async move {
|
self.reload_task = Some(cx.spawn(|this, mut cx| async move {
|
||||||
@ -1085,7 +1082,7 @@ impl Buffer {
|
|||||||
|
|
||||||
/// Sets the text that will be used to compute a Git diff
|
/// Sets the text that will be used to compute a Git diff
|
||||||
/// against the buffer text.
|
/// against the buffer text.
|
||||||
pub fn set_diff_base(&mut self, diff_base: Option<String>, cx: &mut ModelContext<Self>) {
|
pub fn set_diff_base(&mut self, diff_base: Option<String>, cx: &ModelContext<Self>) {
|
||||||
self.diff_base = diff_base.map(|mut raw_diff_base| {
|
self.diff_base = diff_base.map(|mut raw_diff_base| {
|
||||||
LineEnding::normalize(&mut raw_diff_base);
|
LineEnding::normalize(&mut raw_diff_base);
|
||||||
BufferDiffBase::Git(Rope::from(raw_diff_base))
|
BufferDiffBase::Git(Rope::from(raw_diff_base))
|
||||||
@ -1117,7 +1114,7 @@ impl Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Recomputes the diff.
|
/// Recomputes the diff.
|
||||||
pub fn recalculate_diff(&mut self, cx: &mut ModelContext<Self>) -> Option<Task<()>> {
|
pub fn recalculate_diff(&self, cx: &ModelContext<Self>) -> Option<Task<()>> {
|
||||||
let diff_base_rope = match self.diff_base.as_ref()? {
|
let diff_base_rope = match self.diff_base.as_ref()? {
|
||||||
BufferDiffBase::Git(rope) => rope.clone(),
|
BufferDiffBase::Git(rope) => rope.clone(),
|
||||||
BufferDiffBase::PastBufferVersion { buffer, .. } => buffer.read(cx).as_rope().clone(),
|
BufferDiffBase::PastBufferVersion { buffer, .. } => buffer.read(cx).as_rope().clone(),
|
||||||
@ -2249,12 +2246,7 @@ impl Buffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_operation(
|
fn send_operation(&self, operation: Operation, is_local: bool, cx: &mut ModelContext<Self>) {
|
||||||
&mut self,
|
|
||||||
operation: Operation,
|
|
||||||
is_local: bool,
|
|
||||||
cx: &mut ModelContext<Self>,
|
|
||||||
) {
|
|
||||||
cx.emit(BufferEvent::Operation {
|
cx.emit(BufferEvent::Operation {
|
||||||
operation,
|
operation,
|
||||||
is_local,
|
is_local,
|
||||||
|
@ -71,7 +71,7 @@ impl Markdown {
|
|||||||
source: String,
|
source: String,
|
||||||
style: MarkdownStyle,
|
style: MarkdownStyle,
|
||||||
language_registry: Option<Arc<LanguageRegistry>>,
|
language_registry: Option<Arc<LanguageRegistry>>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &ViewContext<Self>,
|
||||||
fallback_code_block_language: Option<String>,
|
fallback_code_block_language: Option<String>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let focus_handle = cx.focus_handle();
|
let focus_handle = cx.focus_handle();
|
||||||
@ -97,7 +97,7 @@ impl Markdown {
|
|||||||
source: String,
|
source: String,
|
||||||
style: MarkdownStyle,
|
style: MarkdownStyle,
|
||||||
language_registry: Option<Arc<LanguageRegistry>>,
|
language_registry: Option<Arc<LanguageRegistry>>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &ViewContext<Self>,
|
||||||
fallback_code_block_language: Option<String>,
|
fallback_code_block_language: Option<String>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let focus_handle = cx.focus_handle();
|
let focus_handle = cx.focus_handle();
|
||||||
@ -119,12 +119,12 @@ impl Markdown {
|
|||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn append(&mut self, text: &str, cx: &mut ViewContext<Self>) {
|
pub fn append(&mut self, text: &str, cx: &ViewContext<Self>) {
|
||||||
self.source.push_str(text);
|
self.source.push_str(text);
|
||||||
self.parse(cx);
|
self.parse(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset(&mut self, source: String, cx: &mut ViewContext<Self>) {
|
pub fn reset(&mut self, source: String, cx: &ViewContext<Self>) {
|
||||||
if source == self.source() {
|
if source == self.source() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ impl Markdown {
|
|||||||
&self.parsed_markdown
|
&self.parsed_markdown
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy(&self, text: &RenderedText, cx: &mut ViewContext<Self>) {
|
fn copy(&self, text: &RenderedText, cx: &ViewContext<Self>) {
|
||||||
if self.selection.end <= self.selection.start {
|
if self.selection.end <= self.selection.start {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ impl Markdown {
|
|||||||
cx.write_to_clipboard(ClipboardItem::new_string(text));
|
cx.write_to_clipboard(ClipboardItem::new_string(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(&mut self, cx: &mut ViewContext<Self>) {
|
fn parse(&mut self, cx: &ViewContext<Self>) {
|
||||||
if self.source.is_empty() {
|
if self.source.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ impl MarkdownElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn paint_selection(
|
fn paint_selection(
|
||||||
&mut self,
|
&self,
|
||||||
bounds: Bounds<Pixels>,
|
bounds: Bounds<Pixels>,
|
||||||
rendered_text: &RenderedText,
|
rendered_text: &RenderedText,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
@ -382,7 +382,7 @@ impl MarkdownElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn paint_mouse_listeners(
|
fn paint_mouse_listeners(
|
||||||
&mut self,
|
&self,
|
||||||
hitbox: &Hitbox,
|
hitbox: &Hitbox,
|
||||||
rendered_text: &RenderedText,
|
rendered_text: &RenderedText,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
@ -487,7 +487,7 @@ impl MarkdownElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn autoscroll(&mut self, rendered_text: &RenderedText, cx: &mut WindowContext) -> Option<()> {
|
fn autoscroll(&self, rendered_text: &RenderedText, cx: &mut WindowContext) -> Option<()> {
|
||||||
let autoscroll_index = self
|
let autoscroll_index = self
|
||||||
.markdown
|
.markdown
|
||||||
.update(cx, |markdown, _| markdown.autoscroll_request.take())?;
|
.update(cx, |markdown, _| markdown.autoscroll_request.take())?;
|
||||||
|
@ -515,7 +515,7 @@ impl MultiBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn edit<I, S, T>(
|
pub fn edit<I, S, T>(
|
||||||
&mut self,
|
&self,
|
||||||
edits: I,
|
edits: I,
|
||||||
mut autoindent_mode: Option<AutoindentMode>,
|
mut autoindent_mode: Option<AutoindentMode>,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
@ -664,7 +664,7 @@ impl MultiBuffer {
|
|||||||
drop(snapshot);
|
drop(snapshot);
|
||||||
// Non-generic part of edit, hoisted out to avoid blowing up LLVM IR.
|
// Non-generic part of edit, hoisted out to avoid blowing up LLVM IR.
|
||||||
fn tail(
|
fn tail(
|
||||||
this: &mut MultiBuffer,
|
this: &MultiBuffer,
|
||||||
buffer_edits: HashMap<BufferId, Vec<BufferEdit>>,
|
buffer_edits: HashMap<BufferId, Vec<BufferEdit>>,
|
||||||
autoindent_mode: Option<AutoindentMode>,
|
autoindent_mode: Option<AutoindentMode>,
|
||||||
edited_excerpt_ids: Vec<ExcerptId>,
|
edited_excerpt_ids: Vec<ExcerptId>,
|
||||||
@ -928,7 +928,7 @@ impl MultiBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_transaction<'a, T>(&mut self, buffer_transactions: T, cx: &mut ModelContext<Self>)
|
pub fn push_transaction<'a, T>(&mut self, buffer_transactions: T, cx: &ModelContext<Self>)
|
||||||
where
|
where
|
||||||
T: IntoIterator<Item = (&'a Model<Buffer>, &'a language::Transaction)>,
|
T: IntoIterator<Item = (&'a Model<Buffer>, &'a language::Transaction)>,
|
||||||
{
|
{
|
||||||
@ -952,7 +952,7 @@ impl MultiBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_active_selections(
|
pub fn set_active_selections(
|
||||||
&mut self,
|
&self,
|
||||||
selections: &[Selection<Anchor>],
|
selections: &[Selection<Anchor>],
|
||||||
line_mode: bool,
|
line_mode: bool,
|
||||||
cursor_shape: CursorShape,
|
cursor_shape: CursorShape,
|
||||||
@ -1028,7 +1028,7 @@ impl MultiBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_active_selections(&mut self, cx: &mut ModelContext<Self>) {
|
pub fn remove_active_selections(&self, cx: &mut ModelContext<Self>) {
|
||||||
for buffer in self.buffers.borrow().values() {
|
for buffer in self.buffers.borrow().values() {
|
||||||
buffer
|
buffer
|
||||||
.buffer
|
.buffer
|
||||||
@ -1180,7 +1180,7 @@ impl MultiBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_multiple_excerpts_with_context_lines(
|
pub fn push_multiple_excerpts_with_context_lines(
|
||||||
&mut self,
|
&self,
|
||||||
buffers_with_ranges: Vec<(Model<Buffer>, Vec<Range<text::Anchor>>)>,
|
buffers_with_ranges: Vec<(Model<Buffer>, Vec<Range<text::Anchor>>)>,
|
||||||
context_line_count: u32,
|
context_line_count: u32,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
@ -4208,7 +4208,7 @@ impl History {
|
|||||||
&mut self,
|
&mut self,
|
||||||
buffer_transactions: T,
|
buffer_transactions: T,
|
||||||
now: Instant,
|
now: Instant,
|
||||||
cx: &mut ModelContext<MultiBuffer>,
|
cx: &ModelContext<MultiBuffer>,
|
||||||
) where
|
) where
|
||||||
T: IntoIterator<Item = (&'a Model<Buffer>, &'a language::Transaction)>,
|
T: IntoIterator<Item = (&'a Model<Buffer>, &'a language::Transaction)>,
|
||||||
{
|
{
|
||||||
|
@ -321,7 +321,7 @@ impl SettingsObserver {
|
|||||||
pub async fn handle_update_user_settings(
|
pub async fn handle_update_user_settings(
|
||||||
_: Model<Self>,
|
_: Model<Self>,
|
||||||
envelope: TypedEnvelope<proto::UpdateUserSettings>,
|
envelope: TypedEnvelope<proto::UpdateUserSettings>,
|
||||||
mut cx: AsyncAppContext,
|
cx: AsyncAppContext,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
cx.update_global(move |settings_store: &mut SettingsStore, cx| {
|
cx.update_global(move |settings_store: &mut SettingsStore, cx| {
|
||||||
settings_store.set_user_settings(&envelope.payload.content, cx)
|
settings_store.set_user_settings(&envelope.payload.content, cx)
|
||||||
|
@ -188,7 +188,7 @@ impl ChannelForwarder {
|
|||||||
fn new(
|
fn new(
|
||||||
mut incoming_tx: UnboundedSender<Envelope>,
|
mut incoming_tx: UnboundedSender<Envelope>,
|
||||||
mut outgoing_rx: UnboundedReceiver<Envelope>,
|
mut outgoing_rx: UnboundedReceiver<Envelope>,
|
||||||
cx: &mut AsyncAppContext,
|
cx: &AsyncAppContext,
|
||||||
) -> (Self, UnboundedSender<Envelope>, UnboundedReceiver<Envelope>) {
|
) -> (Self, UnboundedSender<Envelope>, UnboundedReceiver<Envelope>) {
|
||||||
let (quit_tx, mut quit_rx) = mpsc::unbounded::<()>();
|
let (quit_tx, mut quit_rx) = mpsc::unbounded::<()>();
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ impl SshRemoteClient {
|
|||||||
Ok(this)
|
Ok(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reconnect(this: Arc<Self>, cx: &mut AsyncAppContext) -> Result<()> {
|
fn reconnect(this: Arc<Self>, cx: &AsyncAppContext) -> Result<()> {
|
||||||
let Some(state) = this.inner_state.lock().take() else {
|
let Some(state) = this.inner_state.lock().take() else {
|
||||||
return Err(anyhow!("reconnect is already in progress"));
|
return Err(anyhow!("reconnect is already in progress"));
|
||||||
};
|
};
|
||||||
@ -355,7 +355,7 @@ impl SshRemoteClient {
|
|||||||
mut ssh_process: Child,
|
mut ssh_process: Child,
|
||||||
incoming_tx: UnboundedSender<Envelope>,
|
incoming_tx: UnboundedSender<Envelope>,
|
||||||
mut outgoing_rx: UnboundedReceiver<Envelope>,
|
mut outgoing_rx: UnboundedReceiver<Envelope>,
|
||||||
cx: &mut AsyncAppContext,
|
cx: &AsyncAppContext,
|
||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
let mut child_stderr = ssh_process.stderr.take().unwrap();
|
let mut child_stderr = ssh_process.stderr.take().unwrap();
|
||||||
let mut child_stdout = ssh_process.stdout.take().unwrap();
|
let mut child_stdout = ssh_process.stdout.take().unwrap();
|
||||||
|
@ -64,7 +64,7 @@ pub struct AppSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AppSession {
|
impl AppSession {
|
||||||
pub fn new(session: Session, cx: &mut ModelContext<Self>) -> Self {
|
pub fn new(session: Session, cx: &ModelContext<Self>) -> Self {
|
||||||
let _subscriptions = vec![cx.on_app_quit(Self::app_will_quit)];
|
let _subscriptions = vec![cx.on_app_quit(Self::app_will_quit)];
|
||||||
|
|
||||||
let _serialization_task = Some(cx.spawn(|_, cx| async move {
|
let _serialization_task = Some(cx.spawn(|_, cx| async move {
|
||||||
|
@ -77,7 +77,7 @@ pub fn handle_settings_file_changes(
|
|||||||
.set_user_settings(&user_settings_content, cx)
|
.set_user_settings(&user_settings_content, cx)
|
||||||
.log_err();
|
.log_err();
|
||||||
});
|
});
|
||||||
cx.spawn(move |mut cx| async move {
|
cx.spawn(move |cx| async move {
|
||||||
while let Some(user_settings_content) = user_settings_file_rx.next().await {
|
while let Some(user_settings_content) = user_settings_file_rx.next().await {
|
||||||
let result = cx.update_global(|store: &mut SettingsStore, cx| {
|
let result = cx.update_global(|store: &mut SettingsStore, cx| {
|
||||||
let result = store.set_user_settings(&user_settings_content, cx);
|
let result = store.set_user_settings(&user_settings_content, cx);
|
||||||
|
@ -179,7 +179,7 @@ impl SnippetProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add directory to be watched for content changes
|
/// Add directory to be watched for content changes
|
||||||
fn watch_directory(&mut self, path: &Path, cx: &mut ModelContext<Self>) {
|
fn watch_directory(&mut self, path: &Path, cx: &ModelContext<Self>) {
|
||||||
let path: Arc<Path> = Arc::from(path);
|
let path: Arc<Path> = Arc::from(path);
|
||||||
|
|
||||||
self.watch_tasks.push(cx.spawn(|this, mut cx| async move {
|
self.watch_tasks.push(cx.spawn(|this, mut cx| async move {
|
||||||
|
@ -27,7 +27,7 @@ impl<T: PartialEq + 'static + Sync> TrackedFile<T> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
mut tracker: UnboundedReceiver<String>,
|
mut tracker: UnboundedReceiver<String>,
|
||||||
notification_outlet: UnboundedSender<()>,
|
notification_outlet: UnboundedSender<()>,
|
||||||
cx: &mut AppContext,
|
cx: &AppContext,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
T: for<'a> Deserialize<'a> + Default + Send,
|
T: for<'a> Deserialize<'a> + Default + Send,
|
||||||
@ -69,7 +69,7 @@ impl<T: PartialEq + 'static + Sync> TrackedFile<T> {
|
|||||||
pub fn new_convertible<U: for<'a> Deserialize<'a> + TryInto<T, Error = anyhow::Error>>(
|
pub fn new_convertible<U: for<'a> Deserialize<'a> + TryInto<T, Error = anyhow::Error>>(
|
||||||
mut tracker: UnboundedReceiver<String>,
|
mut tracker: UnboundedReceiver<String>,
|
||||||
notification_outlet: UnboundedSender<()>,
|
notification_outlet: UnboundedSender<()>,
|
||||||
cx: &mut AppContext,
|
cx: &AppContext,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
T: Default + Send,
|
T: Default + Send,
|
||||||
|
@ -320,7 +320,7 @@ impl TerminalBuilder {
|
|||||||
max_scroll_history_lines: Option<usize>,
|
max_scroll_history_lines: Option<usize>,
|
||||||
window: AnyWindowHandle,
|
window: AnyWindowHandle,
|
||||||
completion_tx: Sender<()>,
|
completion_tx: Sender<()>,
|
||||||
cx: &mut AppContext,
|
cx: &AppContext,
|
||||||
) -> Result<TerminalBuilder> {
|
) -> Result<TerminalBuilder> {
|
||||||
// TODO: Properly set the current locale,
|
// TODO: Properly set the current locale,
|
||||||
env.entry("LC_ALL".to_string())
|
env.entry("LC_ALL".to_string())
|
||||||
@ -455,7 +455,7 @@ impl TerminalBuilder {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subscribe(mut self, cx: &mut ModelContext<Terminal>) -> Terminal {
|
pub fn subscribe(mut self, cx: &ModelContext<Terminal>) -> Terminal {
|
||||||
//Event loop
|
//Event loop
|
||||||
cx.spawn(|terminal, mut cx| async move {
|
cx.spawn(|terminal, mut cx| async move {
|
||||||
while let Some(event) = self.events_rx.next().await {
|
while let Some(event) = self.events_rx.next().await {
|
||||||
@ -1280,7 +1280,7 @@ impl Terminal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drag_line_delta(&mut self, e: &MouseMoveEvent, region: Bounds<Pixels>) -> Option<Pixels> {
|
fn drag_line_delta(&self, e: &MouseMoveEvent, region: Bounds<Pixels>) -> Option<Pixels> {
|
||||||
//TODO: Why do these need to be doubled? Probably the same problem that the IME has
|
//TODO: Why do these need to be doubled? Probably the same problem that the IME has
|
||||||
let top = region.origin.y + (self.last_content.size.line_height * 2.);
|
let top = region.origin.y + (self.last_content.size.line_height * 2.);
|
||||||
let bottom = region.lower_left().y - (self.last_content.size.line_height * 2.);
|
let bottom = region.lower_left().y - (self.last_content.size.line_height * 2.);
|
||||||
@ -1351,12 +1351,7 @@ impl Terminal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mouse_up(
|
pub fn mouse_up(&mut self, e: &MouseUpEvent, origin: Point<Pixels>, cx: &ModelContext<Self>) {
|
||||||
&mut self,
|
|
||||||
e: &MouseUpEvent,
|
|
||||||
origin: Point<Pixels>,
|
|
||||||
cx: &mut ModelContext<Self>,
|
|
||||||
) {
|
|
||||||
let setting = TerminalSettings::get_global(cx);
|
let setting = TerminalSettings::get_global(cx);
|
||||||
|
|
||||||
let position = e.position - origin;
|
let position = e.position - origin;
|
||||||
@ -1458,9 +1453,9 @@ impl Terminal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_matches(
|
pub fn find_matches(
|
||||||
&mut self,
|
&self,
|
||||||
mut searcher: RegexSearch,
|
mut searcher: RegexSearch,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Task<Vec<RangeInclusive<AlacPoint>>> {
|
) -> Task<Vec<RangeInclusive<AlacPoint>>> {
|
||||||
let term = self.term.clone();
|
let term = self.term.clone();
|
||||||
cx.background_executor().spawn(async move {
|
cx.background_executor().spawn(async move {
|
||||||
@ -1530,7 +1525,7 @@ impl Terminal {
|
|||||||
self.task.as_ref()
|
self.task.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait_for_completed_task(&self, cx: &mut AppContext) -> Task<()> {
|
pub fn wait_for_completed_task(&self, cx: &AppContext) -> Task<()> {
|
||||||
if let Some(task) = self.task() {
|
if let Some(task) = self.task() {
|
||||||
if task.status == TaskStatus::Running {
|
if task.status == TaskStatus::Running {
|
||||||
let mut completion_receiver = task.completion_rx.clone();
|
let mut completion_receiver = task.completion_rx.clone();
|
||||||
|
@ -189,7 +189,7 @@ impl ThemeRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all themes from the registry.
|
/// Removes all themes from the registry.
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&self) {
|
||||||
self.state.write().themes.clear();
|
self.state.write().themes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ pub fn observe_buffer_font_size_adjustment<V: 'static>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the adjusted buffer font size.
|
/// Sets the adjusted buffer font size.
|
||||||
pub fn adjusted_font_size(size: Pixels, cx: &mut AppContext) -> Pixels {
|
pub fn adjusted_font_size(size: Pixels, cx: &AppContext) -> Pixels {
|
||||||
if let Some(AdjustedBufferFontSize(adjusted_size)) = cx.try_global::<AdjustedBufferFontSize>() {
|
if let Some(AdjustedBufferFontSize(adjusted_size)) = cx.try_global::<AdjustedBufferFontSize>() {
|
||||||
let buffer_font_size = ThemeSettings::get_global(cx).buffer_font_size;
|
let buffer_font_size = ThemeSettings::get_global(cx).buffer_font_size;
|
||||||
let delta = *adjusted_size - buffer_font_size;
|
let delta = *adjusted_size - buffer_font_size;
|
||||||
@ -530,7 +530,7 @@ pub fn adjust_buffer_font_size(cx: &mut AppContext, f: fn(&mut Pixels)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the buffer font size has been adjusted.
|
/// Returns whether the buffer font size has been adjusted.
|
||||||
pub fn has_adjusted_buffer_font_size(cx: &mut AppContext) -> bool {
|
pub fn has_adjusted_buffer_font_size(cx: &AppContext) -> bool {
|
||||||
cx.has_global::<AdjustedBufferFontSize>()
|
cx.has_global::<AdjustedBufferFontSize>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +576,7 @@ pub fn adjust_ui_font_size(cx: &mut AppContext, f: fn(&mut Pixels)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the UI font size has been adjusted.
|
/// Returns whether the UI font size has been adjusted.
|
||||||
pub fn has_adjusted_ui_font_size(cx: &mut AppContext) -> bool {
|
pub fn has_adjusted_ui_font_size(cx: &AppContext) -> bool {
|
||||||
cx.has_global::<AdjustedUiFontSize>()
|
cx.has_global::<AdjustedUiFontSize>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ impl Worktree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn root_file(&self, cx: &mut ModelContext<Self>) -> Option<Arc<File>> {
|
pub fn root_file(&self, cx: &ModelContext<Self>) -> Option<Arc<File>> {
|
||||||
let entry = self.root_entry()?;
|
let entry = self.root_entry()?;
|
||||||
Some(File::for_entry(entry.clone(), cx.handle()))
|
Some(File::for_entry(entry.clone(), cx.handle()))
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ impl Worktree {
|
|||||||
pub fn observe_updates<F, Fut>(
|
pub fn observe_updates<F, Fut>(
|
||||||
&mut self,
|
&mut self,
|
||||||
project_id: u64,
|
project_id: u64,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
callback: F,
|
callback: F,
|
||||||
) where
|
) where
|
||||||
F: 'static + Send + Fn(proto::UpdateWorktree) -> Fut,
|
F: 'static + Send + Fn(proto::UpdateWorktree) -> Fut,
|
||||||
@ -661,11 +661,7 @@ impl Worktree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_file(
|
pub fn load_file(&self, path: &Path, cx: &ModelContext<Worktree>) -> Task<Result<LoadedFile>> {
|
||||||
&self,
|
|
||||||
path: &Path,
|
|
||||||
cx: &mut ModelContext<Worktree>,
|
|
||||||
) -> Task<Result<LoadedFile>> {
|
|
||||||
match self {
|
match self {
|
||||||
Worktree::Local(this) => this.load_file(path, cx),
|
Worktree::Local(this) => this.load_file(path, cx),
|
||||||
Worktree::Remote(_) => {
|
Worktree::Remote(_) => {
|
||||||
@ -679,7 +675,7 @@ impl Worktree {
|
|||||||
path: &Path,
|
path: &Path,
|
||||||
text: Rope,
|
text: Rope,
|
||||||
line_ending: LineEnding,
|
line_ending: LineEnding,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<Arc<File>>> {
|
) -> Task<Result<Arc<File>>> {
|
||||||
match self {
|
match self {
|
||||||
Worktree::Local(this) => this.write_file(path, text, line_ending, cx),
|
Worktree::Local(this) => this.write_file(path, text, line_ending, cx),
|
||||||
@ -693,7 +689,7 @@ impl Worktree {
|
|||||||
&mut self,
|
&mut self,
|
||||||
path: impl Into<Arc<Path>>,
|
path: impl Into<Arc<Path>>,
|
||||||
is_directory: bool,
|
is_directory: bool,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<CreatedEntry>> {
|
) -> Task<Result<CreatedEntry>> {
|
||||||
let path = path.into();
|
let path = path.into();
|
||||||
let worktree_id = self.id();
|
let worktree_id = self.id();
|
||||||
@ -773,7 +769,7 @@ impl Worktree {
|
|||||||
&mut self,
|
&mut self,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
new_path: impl Into<Arc<Path>>,
|
new_path: impl Into<Arc<Path>>,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Task<Result<CreatedEntry>> {
|
) -> Task<Result<CreatedEntry>> {
|
||||||
let new_path = new_path.into();
|
let new_path = new_path.into();
|
||||||
match self {
|
match self {
|
||||||
@ -787,7 +783,7 @@ impl Worktree {
|
|||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
relative_worktree_source_path: Option<PathBuf>,
|
relative_worktree_source_path: Option<PathBuf>,
|
||||||
new_path: impl Into<Arc<Path>>,
|
new_path: impl Into<Arc<Path>>,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &ModelContext<Self>,
|
||||||
) -> Task<Result<Option<Entry>>> {
|
) -> Task<Result<Option<Entry>>> {
|
||||||
let new_path = new_path.into();
|
let new_path = new_path.into();
|
||||||
match self {
|
match self {
|
||||||
@ -830,7 +826,7 @@ impl Worktree {
|
|||||||
target_directory: PathBuf,
|
target_directory: PathBuf,
|
||||||
paths: Vec<Arc<Path>>,
|
paths: Vec<Arc<Path>>,
|
||||||
overwrite_existing_files: bool,
|
overwrite_existing_files: bool,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<Vec<ProjectEntryId>>> {
|
) -> Task<Result<Vec<ProjectEntryId>>> {
|
||||||
match self {
|
match self {
|
||||||
Worktree::Local(this) => {
|
Worktree::Local(this) => {
|
||||||
@ -845,7 +841,7 @@ impl Worktree {
|
|||||||
pub fn expand_entry(
|
pub fn expand_entry(
|
||||||
&mut self,
|
&mut self,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Option<Task<Result<()>>> {
|
) -> Option<Task<Result<()>>> {
|
||||||
match self {
|
match self {
|
||||||
Worktree::Local(this) => this.expand_entry(entry_id, cx),
|
Worktree::Local(this) => this.expand_entry(entry_id, cx),
|
||||||
@ -987,7 +983,7 @@ impl LocalWorktree {
|
|||||||
!self.share_private_files && self.settings.is_path_private(path)
|
!self.share_private_files && self.settings.is_path_private(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn restart_background_scanners(&mut self, cx: &mut ModelContext<Worktree>) {
|
fn restart_background_scanners(&mut self, cx: &ModelContext<Worktree>) {
|
||||||
let (scan_requests_tx, scan_requests_rx) = channel::unbounded();
|
let (scan_requests_tx, scan_requests_rx) = channel::unbounded();
|
||||||
let (path_prefixes_to_scan_tx, path_prefixes_to_scan_rx) = channel::unbounded();
|
let (path_prefixes_to_scan_tx, path_prefixes_to_scan_rx) = channel::unbounded();
|
||||||
self.scan_requests_tx = scan_requests_tx;
|
self.scan_requests_tx = scan_requests_tx;
|
||||||
@ -999,7 +995,7 @@ impl LocalWorktree {
|
|||||||
&mut self,
|
&mut self,
|
||||||
scan_requests_rx: channel::Receiver<ScanRequest>,
|
scan_requests_rx: channel::Receiver<ScanRequest>,
|
||||||
path_prefixes_to_scan_rx: channel::Receiver<Arc<Path>>,
|
path_prefixes_to_scan_rx: channel::Receiver<Arc<Path>>,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) {
|
) {
|
||||||
let snapshot = self.snapshot();
|
let snapshot = self.snapshot();
|
||||||
let share_private_files = self.share_private_files;
|
let share_private_files = self.share_private_files;
|
||||||
@ -1236,7 +1232,7 @@ impl LocalWorktree {
|
|||||||
self.git_repositories.get(&repo.work_directory.0)
|
self.git_repositories.get(&repo.work_directory.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_file(&self, path: &Path, cx: &mut ModelContext<Worktree>) -> Task<Result<LoadedFile>> {
|
fn load_file(&self, path: &Path, cx: &ModelContext<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();
|
||||||
@ -1318,7 +1314,7 @@ impl LocalWorktree {
|
|||||||
&self,
|
&self,
|
||||||
path: impl Into<Arc<Path>>,
|
path: impl Into<Arc<Path>>,
|
||||||
is_dir: bool,
|
is_dir: bool,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<CreatedEntry>> {
|
) -> Task<Result<CreatedEntry>> {
|
||||||
let path = path.into();
|
let path = path.into();
|
||||||
let abs_path = match self.absolutize(&path) {
|
let abs_path = match self.absolutize(&path) {
|
||||||
@ -1383,7 +1379,7 @@ impl LocalWorktree {
|
|||||||
path: impl Into<Arc<Path>>,
|
path: impl Into<Arc<Path>>,
|
||||||
text: Rope,
|
text: Rope,
|
||||||
line_ending: LineEnding,
|
line_ending: LineEnding,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<Arc<File>>> {
|
) -> Task<Result<Arc<File>>> {
|
||||||
let path = path.into();
|
let path = path.into();
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
@ -1437,7 +1433,7 @@ impl LocalWorktree {
|
|||||||
&self,
|
&self,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
trash: bool,
|
trash: bool,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Option<Task<Result<()>>> {
|
) -> Option<Task<Result<()>>> {
|
||||||
let entry = self.entry_for_id(entry_id)?.clone();
|
let entry = self.entry_for_id(entry_id)?.clone();
|
||||||
let abs_path = self.absolutize(&entry.path);
|
let abs_path = self.absolutize(&entry.path);
|
||||||
@ -1489,7 +1485,7 @@ impl LocalWorktree {
|
|||||||
&self,
|
&self,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
new_path: impl Into<Arc<Path>>,
|
new_path: impl Into<Arc<Path>>,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<CreatedEntry>> {
|
) -> Task<Result<CreatedEntry>> {
|
||||||
let old_path = match self.entry_for_id(entry_id) {
|
let old_path = match self.entry_for_id(entry_id) {
|
||||||
Some(entry) => entry.path.clone(),
|
Some(entry) => entry.path.clone(),
|
||||||
@ -1547,7 +1543,7 @@ impl LocalWorktree {
|
|||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
relative_worktree_source_path: Option<PathBuf>,
|
relative_worktree_source_path: Option<PathBuf>,
|
||||||
new_path: impl Into<Arc<Path>>,
|
new_path: impl Into<Arc<Path>>,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<Option<Entry>>> {
|
) -> Task<Result<Option<Entry>>> {
|
||||||
let old_path = match self.entry_for_id(entry_id) {
|
let old_path = match self.entry_for_id(entry_id) {
|
||||||
Some(entry) => entry.path.clone(),
|
Some(entry) => entry.path.clone(),
|
||||||
@ -1584,11 +1580,11 @@ impl LocalWorktree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_external_entries(
|
pub fn copy_external_entries(
|
||||||
&mut self,
|
&self,
|
||||||
target_directory: PathBuf,
|
target_directory: PathBuf,
|
||||||
paths: Vec<Arc<Path>>,
|
paths: Vec<Arc<Path>>,
|
||||||
overwrite_existing_files: bool,
|
overwrite_existing_files: bool,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<Vec<ProjectEntryId>>> {
|
) -> Task<Result<Vec<ProjectEntryId>>> {
|
||||||
let worktree_path = self.abs_path().clone();
|
let worktree_path = self.abs_path().clone();
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
@ -1665,9 +1661,9 @@ impl LocalWorktree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn expand_entry(
|
fn expand_entry(
|
||||||
&mut self,
|
&self,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Option<Task<Result<()>>> {
|
) -> Option<Task<Result<()>>> {
|
||||||
let path = self.entry_for_id(entry_id)?.path.clone();
|
let path = self.entry_for_id(entry_id)?.path.clone();
|
||||||
let mut refresh = self.refresh_entries_for_paths(vec![path]);
|
let mut refresh = self.refresh_entries_for_paths(vec![path]);
|
||||||
@ -1696,7 +1692,7 @@ impl LocalWorktree {
|
|||||||
&self,
|
&self,
|
||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
old_path: Option<Arc<Path>>,
|
old_path: Option<Arc<Path>>,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<Option<Entry>>> {
|
) -> Task<Result<Option<Entry>>> {
|
||||||
if self.settings.is_path_excluded(&path) {
|
if self.settings.is_path_excluded(&path) {
|
||||||
return Task::ready(Ok(None));
|
return Task::ready(Ok(None));
|
||||||
@ -1720,12 +1716,8 @@ impl LocalWorktree {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn observe_updates<F, Fut>(
|
fn observe_updates<F, Fut>(&mut self, project_id: u64, cx: &ModelContext<Worktree>, callback: F)
|
||||||
&mut self,
|
where
|
||||||
project_id: u64,
|
|
||||||
cx: &mut ModelContext<Worktree>,
|
|
||||||
callback: F,
|
|
||||||
) where
|
|
||||||
F: 'static + Send + Fn(proto::UpdateWorktree) -> Fut,
|
F: 'static + Send + Fn(proto::UpdateWorktree) -> Fut,
|
||||||
Fut: Send + Future<Output = bool>,
|
Fut: Send + Future<Output = bool>,
|
||||||
{
|
{
|
||||||
@ -1784,7 +1776,7 @@ impl LocalWorktree {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn share_private_files(&mut self, cx: &mut ModelContext<Worktree>) {
|
pub fn share_private_files(&mut self, cx: &ModelContext<Worktree>) {
|
||||||
self.share_private_files = true;
|
self.share_private_files = true;
|
||||||
self.restart_background_scanners(cx);
|
self.restart_background_scanners(cx);
|
||||||
}
|
}
|
||||||
@ -1805,7 +1797,7 @@ impl RemoteWorktree {
|
|||||||
self.disconnected = true;
|
self.disconnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_from_remote(&mut self, update: proto::UpdateWorktree) {
|
pub fn update_from_remote(&self, update: proto::UpdateWorktree) {
|
||||||
if let Some(updates_tx) = &self.updates_tx {
|
if let Some(updates_tx) = &self.updates_tx {
|
||||||
updates_tx
|
updates_tx
|
||||||
.unbounded_send(update)
|
.unbounded_send(update)
|
||||||
@ -1813,12 +1805,8 @@ impl RemoteWorktree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn observe_updates<F, Fut>(
|
fn observe_updates<F, Fut>(&mut self, project_id: u64, cx: &ModelContext<Worktree>, callback: F)
|
||||||
&mut self,
|
where
|
||||||
project_id: u64,
|
|
||||||
cx: &mut ModelContext<Worktree>,
|
|
||||||
callback: F,
|
|
||||||
) where
|
|
||||||
F: 'static + Send + Fn(proto::UpdateWorktree) -> Fut,
|
F: 'static + Send + Fn(proto::UpdateWorktree) -> Fut,
|
||||||
Fut: 'static + Send + Future<Output = bool>,
|
Fut: 'static + Send + Future<Output = bool>,
|
||||||
{
|
{
|
||||||
@ -1879,7 +1867,7 @@ impl RemoteWorktree {
|
|||||||
&mut self,
|
&mut self,
|
||||||
entry: proto::Entry,
|
entry: proto::Entry,
|
||||||
scan_id: usize,
|
scan_id: usize,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<Entry>> {
|
) -> Task<Result<Entry>> {
|
||||||
let wait_for_snapshot = self.wait_for_snapshot(scan_id);
|
let wait_for_snapshot = self.wait_for_snapshot(scan_id);
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
@ -1895,10 +1883,10 @@ impl RemoteWorktree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn delete_entry(
|
fn delete_entry(
|
||||||
&mut self,
|
&self,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
trash: bool,
|
trash: bool,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Option<Task<Result<()>>> {
|
) -> Option<Task<Result<()>>> {
|
||||||
let response = self.client.request(proto::DeleteProjectEntry {
|
let response = self.client.request(proto::DeleteProjectEntry {
|
||||||
project_id: self.project_id,
|
project_id: self.project_id,
|
||||||
@ -1924,10 +1912,10 @@ impl RemoteWorktree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rename_entry(
|
fn rename_entry(
|
||||||
&mut self,
|
&self,
|
||||||
entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
new_path: impl Into<Arc<Path>>,
|
new_path: impl Into<Arc<Path>>,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &ModelContext<Worktree>,
|
||||||
) -> Task<Result<CreatedEntry>> {
|
) -> Task<Result<CreatedEntry>> {
|
||||||
let new_path = new_path.into();
|
let new_path = new_path.into();
|
||||||
let response = self.client.request(proto::RenameProjectEntry {
|
let response = self.client.request(proto::RenameProjectEntry {
|
||||||
@ -3692,7 +3680,7 @@ impl BackgroundScanner {
|
|||||||
self.send_status_update(scanning, request.done)
|
self.send_status_update(scanning, request.done)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_events(&mut self, mut abs_paths: Vec<PathBuf>) {
|
async fn process_events(&self, mut abs_paths: Vec<PathBuf>) {
|
||||||
let root_path = self.state.lock().snapshot.abs_path.clone();
|
let root_path = self.state.lock().snapshot.abs_path.clone();
|
||||||
let root_canonical_path = match self.fs.canonicalize(&root_path).await {
|
let root_canonical_path = match self.fs.canonicalize(&root_path).await {
|
||||||
Ok(path) => path,
|
Ok(path) => path,
|
||||||
|
@ -347,7 +347,7 @@ pub fn monitor_main_thread_hangs(
|
|||||||
fn upload_panics_and_crashes(
|
fn upload_panics_and_crashes(
|
||||||
http: Arc<HttpClientWithUrl>,
|
http: Arc<HttpClientWithUrl>,
|
||||||
installation_id: Option<String>,
|
installation_id: Option<String>,
|
||||||
cx: &mut AppContext,
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let telemetry_settings = *client::TelemetrySettings::get_global(cx);
|
let telemetry_settings = *client::TelemetrySettings::get_global(cx);
|
||||||
cx.background_executor()
|
cx.background_executor()
|
||||||
|
@ -573,7 +573,7 @@ fn feature_gate_zed_pro_actions(cx: &mut AppContext) {
|
|||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize_pane(workspace: &mut Workspace, pane: &View<Pane>, cx: &mut ViewContext<Workspace>) {
|
fn initialize_pane(workspace: &Workspace, pane: &View<Pane>, cx: &mut ViewContext<Workspace>) {
|
||||||
pane.update(cx, |pane, cx| {
|
pane.update(cx, |pane, cx| {
|
||||||
pane.toolbar().update(cx, |toolbar, cx| {
|
pane.toolbar().update(cx, |toolbar, cx| {
|
||||||
let multibuffer_hint = cx.new_view(|_| MultibufferHint::new());
|
let multibuffer_hint = cx.new_view(|_| MultibufferHint::new());
|
||||||
@ -981,7 +981,7 @@ fn open_telemetry_log_file(workspace: &mut Workspace, cx: &mut ViewContext<Works
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn open_bundled_file(
|
fn open_bundled_file(
|
||||||
workspace: &mut Workspace,
|
workspace: &Workspace,
|
||||||
text: Cow<'static, str>,
|
text: Cow<'static, str>,
|
||||||
title: &'static str,
|
title: &'static str,
|
||||||
language: &'static str,
|
language: &'static str,
|
||||||
|
@ -64,7 +64,7 @@ pub fn init(telemetry: Arc<Telemetry>, cx: &mut AppContext) {
|
|||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_backward_compatible_actions(editor: &mut Editor, cx: &mut ViewContext<Editor>) {
|
fn register_backward_compatible_actions(editor: &mut Editor, cx: &ViewContext<Editor>) {
|
||||||
// We renamed some of these actions to not be copilot-specific, but that
|
// We renamed some of these actions to not be copilot-specific, but that
|
||||||
// would have not been backwards-compatible. So here we are re-registering
|
// would have not been backwards-compatible. So here we are re-registering
|
||||||
// the actions with the old names to not break people's keymaps.
|
// the actions with the old names to not break people's keymaps.
|
||||||
|
@ -661,7 +661,7 @@ mod tests {
|
|||||||
path: &str,
|
path: &str,
|
||||||
open_new_workspace: Option<bool>,
|
open_new_workspace: Option<bool>,
|
||||||
app_state: Arc<AppState>,
|
app_state: Arc<AppState>,
|
||||||
cx: &mut TestAppContext,
|
cx: &TestAppContext,
|
||||||
) {
|
) {
|
||||||
let (response_tx, _) = ipc::channel::<CliResponse>().unwrap();
|
let (response_tx, _) = ipc::channel::<CliResponse>().unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user