Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same logic for skipping single instance check on Linux as on Mac/Win #19446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions crates/zed/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use node_runtime::{NodeBinaryOptions, NodeRuntime};
use parking_lot::Mutex;
use project::project_settings::ProjectSettings;
use recent_projects::{open_ssh_project, SshSettings};
use release_channel::{AppCommitSha, AppVersion};
use release_channel::{AppCommitSha, AppVersion, ReleaseChannel};
use session::{AppSession, Session};
use settings::{
handle_settings_file_changes, watch_config_file, InvalidSettingsError, Settings, SettingsStore,
Expand Down Expand Up @@ -353,32 +353,29 @@ fn main() {

let (open_listener, mut open_rx) = OpenListener::new();

#[cfg(target_os = "linux")]
{
if env::var("ZED_STATELESS").is_err() {
if crate::zed::listen_for_cli_connections(open_listener.clone()).is_err() {
println!("zed is already running");
return;
let failed_single_instance_check =
if *db::ZED_STATELESS || *release_channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
false
} else {
#[cfg(target_os = "linux")]
{
crate::zed::listen_for_cli_connections(open_listener.clone()).is_err()
}
}
}

#[cfg(target_os = "windows")]
{
use zed::windows_only_instance::*;
if !check_single_instance() {
println!("zed is already running");
return;
}
}
#[cfg(target_os = "windows")]
{
!crate::zed::windows_only_instance::check_single_instance()
}

#[cfg(target_os = "macos")]
{
use zed::mac_only_instance::*;
if ensure_only_instance() != IsOnlyInstance::Yes {
println!("zed is already running");
return;
}
#[cfg(target_os = "macos")]
{
use zed::mac_only_instance::*;
ensure_only_instance() != IsOnlyInstance::Yes
}
};
if failed_single_instance_check {
println!("zed is already running");
return;
}

let git_hosting_provider_registry = Arc::new(GitHostingProviderRegistry::new());
Expand Down
4 changes: 0 additions & 4 deletions crates/zed/src/zed/mac_only_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ pub enum IsOnlyInstance {
}

pub fn ensure_only_instance() -> IsOnlyInstance {
if *db::ZED_STATELESS || *release_channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
return IsOnlyInstance::Yes;
}

if check_got_handshake() {
return IsOnlyInstance::No;
}
Expand Down
8 changes: 0 additions & 8 deletions crates/zed/src/zed/windows_only_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ fn retrieve_app_instance_event_identifier() -> &'static str {
}

pub fn check_single_instance() -> bool {
if *db::ZED_STATELESS || *release_channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
return true;
}

check_single_instance_event()
}

fn check_single_instance_event() -> bool {
unsafe {
CreateEventW(
None,
Expand Down
Loading