diff --git a/Cargo.lock b/Cargo.lock index 3f03b2ffcba..01409509025 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22490,6 +22490,7 @@ dependencies = [ "migrator", "mimalloc", "miniprofiler_ui", + "nix 0.30.1", "node_runtime", "notifications", "onboarding", diff --git a/crates/extension_host/src/extension_host.rs b/crates/extension_host/src/extension_host.rs index 14755482835..7d22d2178ee 100644 --- a/crates/extension_host/src/extension_host.rs +++ b/crates/extension_host/src/extension_host.rs @@ -1436,9 +1436,9 @@ impl ExtensionStore { .chain(languages_to_readd.iter().map(|(name, _)| name)) .collect::>(); if !semantic_token_rules_to_remove.is_empty() { - SettingsStore::update_global(cx, |store, cx| { + SettingsStore::update_global(cx, |store, _| { for language in semantic_token_rules_to_remove { - store.remove_language_semantic_token_rules(language.as_ref(), cx); + store.remove_language_semantic_token_rules(language.as_ref()); } }); } @@ -1629,13 +1629,9 @@ impl ExtensionStore { // Register semantic token rules for newly loaded extension languages. if !semantic_token_rules_to_add.is_empty() { this.update(cx, |_, cx| { - SettingsStore::update_global(cx, |store, cx| { + SettingsStore::update_global(cx, |store, _| { for (language_name, rules) in semantic_token_rules_to_add { - store.set_language_semantic_token_rules( - language_name.0.clone(), - rules, - cx, - ); + store.set_language_semantic_token_rules(language_name.0.clone(), rules); } }) }) diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rs index 81d16f7bc06..55b69b09b0a 100644 --- a/crates/gpui_macos/src/window.rs +++ b/crates/gpui_macos/src/window.rs @@ -1788,14 +1788,18 @@ impl PlatformWindow for MacWindow { fn activate(&self) { let lock = self.0.lock(); let window = lock.native_window; + let view = lock.native_view.as_ptr(); let closed = lock.closed.clone(); let executor = lock.foreground_executor.clone(); executor .spawn(async move { if !closed.load(Ordering::Acquire) { - unsafe { - let _: () = msg_send![window, makeKeyAndOrderFront: nil]; + let window = unsafe { &*window.cast::() }; + if !window.isVisible() { + let view = unsafe { &*view.cast::() }; + view.setNeedsDisplay(true); } + window.makeKeyAndOrderFront(None); } }) .detach(); diff --git a/crates/languages/src/lib.rs b/crates/languages/src/lib.rs index cd3d1f09e28..ba00539b41e 100644 --- a/crates/languages/src/lib.rs +++ b/crates/languages/src/lib.rs @@ -355,8 +355,8 @@ fn register_language( ) { let config = load_config(name); if let Some(rules) = &semantic_token_rules { - SettingsStore::update_global(cx, |store, cx| { - store.set_language_semantic_token_rules(config.name.0.clone(), rules.clone(), cx); + SettingsStore::update_global(cx, |store, _| { + store.set_language_semantic_token_rules(config.name.0.clone(), rules.clone()); }); } for adapter in adapters { diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index 73b81193636..1a12c087832 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -1032,27 +1032,17 @@ impl SettingsStore { /// or by third-party extensions (via `semantic_token_rules.json` in their language /// directories). They are stored separately from the global rules and are only /// applied to buffers of the matching language by the `SemanticTokenStylizer`. - /// - /// This triggers a settings recomputation so that observers (e.g. `LspStore`) - /// are notified and can invalidate cached stylizers. pub fn set_language_semantic_token_rules( &mut self, language: SharedString, rules: SemanticTokenRules, - cx: &mut App, ) { self.language_semantic_token_rules.insert(language, rules); - self.recompute_values(None, cx); } /// Removes language-specific semantic token rules for the given language. - /// - /// This should be called when an extension that registered rules for a language - /// is unloaded. Triggers a settings recomputation so that observers (e.g. - /// `LspStore`) are notified and can invalidate cached stylizers. - pub fn remove_language_semantic_token_rules(&mut self, language: &str, cx: &mut App) { + pub fn remove_language_semantic_token_rules(&mut self, language: &str) { self.language_semantic_token_rules.remove(language); - self.recompute_values(None, cx); } /// Returns the language-specific semantic token rules for the given language, diff --git a/crates/sqlez/src/migrations.rs b/crates/sqlez/src/migrations.rs index 193c8e186eb..69dba7f0ad6 100644 --- a/crates/sqlez/src/migrations.rs +++ b/crates/sqlez/src/migrations.rs @@ -61,6 +61,12 @@ impl Connection { let mut did_migrate = false; for (index, migration) in migrations.iter().enumerate() { + if completed_migrations + .get(index) + .is_some_and(|(_, _, completed)| completed.as_str() == *migration) + { + continue; + } let migration = sqlformat::format(migration, &sqlformat::QueryParams::None, Default::default()); if let Some((_, _, completed_migration)) = completed_migrations.get(index) { diff --git a/crates/theme/src/default_colors.rs b/crates/theme/src/default_colors.rs index 7a6cba6697a..c3b6c3b117e 100644 --- a/crates/theme/src/default_colors.rs +++ b/crates/theme/src/default_colors.rs @@ -1,11 +1,13 @@ use gpui::{Hsla, Rgba}; +use std::sync::LazyLock; use crate::ColorScale; use crate::scale::{ColorScaleSet, ColorScales}; use crate::{SystemColors, ThemeColors}; -pub(crate) fn neutral() -> ColorScaleSet { - sand() +pub(crate) fn neutral() -> &'static ColorScaleSet { + static NEUTRAL: LazyLock = LazyLock::new(sand); + &NEUTRAL } const ADDED_COLOR: Hsla = Hsla { diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 6ed5c37e49b..5443b92c5bc 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -236,6 +236,9 @@ zlog.workspace = true zlog_settings.workspace = true ztracing.workspace = true +[target.'cfg(target_os = "macos")'.dependencies] +nix = { workspace = true, features = ["user"] } + [target.'cfg(target_os = "windows")'.dependencies] etw_tracing.workspace = true windows = { workspace = true, features = ["Win32_System_Console", "Win32_System_Pipes"] } diff --git a/crates/zed/src/zed/mac_only_instance.rs b/crates/zed/src/zed/mac_only_instance.rs index b7898fae176..eec89dee8fc 100644 --- a/crates/zed/src/zed/mac_only_instance.rs +++ b/crates/zed/src/zed/mac_only_instance.rs @@ -5,8 +5,7 @@ use std::{ time::Duration, }; -use sysinfo::System; - +use nix::unistd::getuid; use release_channel::ReleaseChannel; const LOCALHOST: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1); @@ -34,42 +33,17 @@ fn address() -> SocketAddr { ReleaseChannel::Stable => 43737 + (2 * USER_BLOCK), ReleaseChannel::Nightly => 43737 + (3 * USER_BLOCK), }; - let mut user_port = port; - let mut sys = System::new_all(); - sys.refresh_all(); - if let Ok(current_pid) = sysinfo::get_current_pid() - && let Some(uid) = sys - .process(current_pid) - .and_then(|process| process.user_id()) - { - let uid_u32 = get_uid_as_u32(uid); - // Ensure that the user ID is not too large to avoid overflow when - // calculating the port number. This seems unlikely but it doesn't - // hurt to be safe. - let max_port = 65535; - let max_uid: u32 = max_port - port as u32; - let wrapped_uid: u16 = (uid_u32 % max_uid) as u16; - user_port += wrapped_uid; - } + let uid = getuid().as_raw(); + // Ensure that the user ID is not too large to avoid overflow when + // calculating the port number. This seems unlikely but it doesn't + // hurt to be safe. + let max_uid = u32::from(u16::MAX) - u32::from(port); + let wrapped_uid = (uid % max_uid) as u16; + let user_port = port + wrapped_uid; SocketAddr::V4(SocketAddrV4::new(LOCALHOST, user_port)) } -#[cfg(unix)] -fn get_uid_as_u32(uid: &sysinfo::Uid) -> u32 { - *uid.clone() -} - -#[cfg(windows)] -fn get_uid_as_u32(uid: &sysinfo::Uid) -> u32 { - // Extract the RID which is an integer - uid.to_string() - .rsplit('-') - .next() - .and_then(|rid| rid.parse::().ok()) - .unwrap_or(0) -} - fn instance_handshake() -> &'static str { match *release_channel::RELEASE_CHANNEL { ReleaseChannel::Dev => "Zed Editor Dev Instance Running",