mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 18:42:31 +03:00
Remove wezterm fork from dependencie (#8998)
Improves build time by removing wezterm dependency ([#8604](https://github.com/zed-industries/zed/issues/8604)). Release Notes: - N/A
This commit is contained in:
parent
e7289c385d
commit
41d8ba12ec
44
Cargo.lock
generated
44
Cargo.lock
generated
@ -5368,9 +5368,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.152"
|
version = "0.2.153"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libgit2-sys"
|
name = "libgit2-sys"
|
||||||
@ -7170,17 +7170,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "procinfo"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "git+https://github.com/zed-industries/wezterm?rev=0c13436f4fa8b126f46dd4a20106419b41666897#0c13436f4fa8b126f46dd4a20106419b41666897"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"log",
|
|
||||||
"ntapi",
|
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "profiling"
|
name = "profiling"
|
||||||
version = "1.0.15"
|
version = "1.0.15"
|
||||||
@ -9609,9 +9598,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sysinfo"
|
name = "sysinfo"
|
||||||
version = "0.29.10"
|
version = "0.30.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0a18d114d420ada3a891e6bc8e96a2023402203296a47cdd65083377dad18ba5"
|
checksum = "0c385888ef380a852a16209afc8cfad22795dd8873d69c9a14d2e2088f118d18"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"core-foundation-sys 0.8.6",
|
"core-foundation-sys 0.8.6",
|
||||||
@ -9619,7 +9608,7 @@ dependencies = [
|
|||||||
"ntapi",
|
"ntapi",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rayon",
|
"rayon",
|
||||||
"winapi 0.3.9",
|
"windows 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -9756,7 +9745,6 @@ dependencies = [
|
|||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"gpui",
|
"gpui",
|
||||||
"libc",
|
"libc",
|
||||||
"procinfo",
|
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
@ -9764,6 +9752,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"settings",
|
"settings",
|
||||||
"smol",
|
"smol",
|
||||||
|
"sysinfo",
|
||||||
"task",
|
"task",
|
||||||
"theme",
|
"theme",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
@ -11998,18 +11987,37 @@ dependencies = [
|
|||||||
"windows-targets 0.48.5",
|
"windows-targets 0.48.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.52.0",
|
||||||
|
"windows-targets 0.52.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.53.0"
|
version = "0.53.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "efc5cf48f83140dcaab716eeaea345f9e93d0018fb81162753a3f76c3397b538"
|
checksum = "efc5cf48f83140dcaab716eeaea345f9e93d0018fb81162753a3f76c3397b538"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-core",
|
"windows-core 0.53.0",
|
||||||
"windows-implement",
|
"windows-implement",
|
||||||
"windows-interface",
|
"windows-interface",
|
||||||
"windows-targets 0.52.4",
|
"windows-targets 0.52.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.53.0"
|
version = "0.53.0"
|
||||||
|
@ -259,7 +259,7 @@ smallvec = { version = "1.6", features = ["union"] }
|
|||||||
smol = "1.2"
|
smol = "1.2"
|
||||||
strum = { version = "0.25.0", features = ["derive"] }
|
strum = { version = "0.25.0", features = ["derive"] }
|
||||||
subtle = "2.5.0"
|
subtle = "2.5.0"
|
||||||
sysinfo = "0.29.10"
|
sysinfo = "0.30.7"
|
||||||
tempfile = "3.9.0"
|
tempfile = "3.9.0"
|
||||||
thiserror = "1.0.29"
|
thiserror = "1.0.29"
|
||||||
tiktoken-rs = "0.5.7"
|
tiktoken-rs = "0.5.7"
|
||||||
|
@ -12,9 +12,7 @@ use settings::{Settings, SettingsStore};
|
|||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
|
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
|
||||||
use sysinfo::{
|
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System};
|
||||||
CpuRefreshKind, Pid, PidExt, ProcessExt, ProcessRefreshKind, RefreshKind, System, SystemExt,
|
|
||||||
};
|
|
||||||
use telemetry_events::{
|
use telemetry_events::{
|
||||||
ActionEvent, AppEvent, AssistantEvent, AssistantKind, CallEvent, CopilotEvent, CpuEvent,
|
ActionEvent, AppEvent, AssistantEvent, AssistantKind, CallEvent, CopilotEvent, CpuEvent,
|
||||||
EditEvent, EditorEvent, Event, EventRequestBody, EventWrapper, MemoryEvent, SettingEvent,
|
EditEvent, EditorEvent, Event, EventRequestBody, EventWrapper, MemoryEvent, SettingEvent,
|
||||||
@ -175,7 +173,7 @@ impl Telemetry {
|
|||||||
cx.spawn(|_| async move {
|
cx.spawn(|_| async move {
|
||||||
// Avoiding calling `System::new_all()`, as there have been crashes related to it
|
// Avoiding calling `System::new_all()`, as there have been crashes related to it
|
||||||
let refresh_kind = RefreshKind::new()
|
let refresh_kind = RefreshKind::new()
|
||||||
.with_memory() // For memory usage
|
.with_memory(MemoryRefreshKind::everything()) // For memory usage
|
||||||
.with_processes(ProcessRefreshKind::everything()) // For process usage
|
.with_processes(ProcessRefreshKind::everything()) // For process usage
|
||||||
.with_cpu(CpuRefreshKind::everything()); // For core count
|
.with_cpu(CpuRefreshKind::everything()); // For core count
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ use human_bytes::human_bytes;
|
|||||||
use release_channel::{AppVersion, ReleaseChannel};
|
use release_channel::{AppVersion, ReleaseChannel};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::{env, fmt::Display};
|
use std::{env, fmt::Display};
|
||||||
use sysinfo::{RefreshKind, System, SystemExt};
|
use sysinfo::{MemoryRefreshKind, RefreshKind, System};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
pub struct SystemSpecs {
|
pub struct SystemSpecs {
|
||||||
@ -20,7 +20,9 @@ impl SystemSpecs {
|
|||||||
let app_version = AppVersion::global(cx).to_string();
|
let app_version = AppVersion::global(cx).to_string();
|
||||||
let release_channel = ReleaseChannel::global(cx).display_name();
|
let release_channel = ReleaseChannel::global(cx).display_name();
|
||||||
let os_name = cx.app_metadata().os_name;
|
let os_name = cx.app_metadata().os_name;
|
||||||
let system = System::new_with_specifics(RefreshKind::new().with_memory());
|
let system = System::new_with_specifics(
|
||||||
|
RefreshKind::new().with_memory(MemoryRefreshKind::everything()),
|
||||||
|
);
|
||||||
let memory = system.total_memory();
|
let memory = system.total_memory();
|
||||||
let architecture = env::consts::ARCH;
|
let architecture = env::consts::ARCH;
|
||||||
let os_version = cx
|
let os_version = cx
|
||||||
|
@ -22,13 +22,13 @@ dirs = "4.0.0"
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "0c13436f4fa8b126f46dd4a20106419b41666897", default-features = false }
|
|
||||||
task.workspace = true
|
task.workspace = true
|
||||||
schemars.workspace = true
|
schemars.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_derive.workspace = true
|
serde_derive.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
|
sysinfo.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
theme.workspace = true
|
theme.workspace = true
|
||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
|
134
crates/terminal/src/pty_info.rs
Normal file
134
crates/terminal/src/pty_info.rs
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
use alacritty_terminal::tty::Pty;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use std::num::NonZeroU32;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use std::os::fd::AsRawFd;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use windows::Win32::{Foundation::HANDLE, System::Threading::GetProcessId};
|
||||||
|
|
||||||
|
use sysinfo::{Pid, Process, ProcessRefreshKind, RefreshKind, System, UpdateKind};
|
||||||
|
|
||||||
|
struct ProcessIdGetter {
|
||||||
|
handle: i32,
|
||||||
|
fallback_pid: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
impl ProcessIdGetter {
|
||||||
|
fn new(pty: &Pty) -> ProcessIdGetter {
|
||||||
|
ProcessIdGetter {
|
||||||
|
handle: pty.file().as_raw_fd(),
|
||||||
|
fallback_pid: pty.child().id(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pid(&self) -> Option<Pid> {
|
||||||
|
let pid = unsafe { libc::tcgetpgrp(self.handle) };
|
||||||
|
if pid < 0 {
|
||||||
|
return Some(Pid::from_u32(self.fallback_pid));
|
||||||
|
}
|
||||||
|
Some(Pid::from_u32(pid as u32))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
impl ProcessIdGetter {
|
||||||
|
fn new(pty: &Pty) -> ProcessIdGetter {
|
||||||
|
let child = pty.child_watcher();
|
||||||
|
let handle = child.raw_handle();
|
||||||
|
let fallback_pid = child
|
||||||
|
.pid()
|
||||||
|
.unwrap_or_else(|| unsafe { NonZeroU32::new_unchecked(GetProcessId(HANDLE(handle))) });
|
||||||
|
|
||||||
|
ProcessIdGetter {
|
||||||
|
handle: handle as i32,
|
||||||
|
fallback_pid: u32::from(fallback_pid),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pid(&self) -> Option<Pid> {
|
||||||
|
let pid = unsafe { GetProcessId(HANDLE(self.handle as _)) };
|
||||||
|
// the GetProcessId may fail and returns zero, which will lead to a stack overflow issue
|
||||||
|
if pid == 0 {
|
||||||
|
// in the builder process, there is a small chance, almost negligible,
|
||||||
|
// that this value could be zero, which means child_watcher returns None,
|
||||||
|
// GetProcessId returns 0.
|
||||||
|
if self.fallback_pid == 0 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
return Some(Pid::from_u32(self.fallback_pid));
|
||||||
|
}
|
||||||
|
Some(Pid::from_u32(pid as u32))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct ProcessInfo {
|
||||||
|
pub name: String,
|
||||||
|
pub cwd: PathBuf,
|
||||||
|
pub argv: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetches Zed-relevant Pseudo-Terminal (PTY) process information
|
||||||
|
pub struct PtyProcessInfo {
|
||||||
|
system: System,
|
||||||
|
refresh_kind: ProcessRefreshKind,
|
||||||
|
pid_getter: ProcessIdGetter,
|
||||||
|
pub current: Option<ProcessInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PtyProcessInfo {
|
||||||
|
pub fn new(pty: &Pty) -> PtyProcessInfo {
|
||||||
|
let process_refresh_kind = ProcessRefreshKind::new()
|
||||||
|
.with_cmd(UpdateKind::Always)
|
||||||
|
.with_cwd(UpdateKind::Always)
|
||||||
|
.with_exe(UpdateKind::Always);
|
||||||
|
let refresh_kind = RefreshKind::new().with_processes(process_refresh_kind);
|
||||||
|
let system = System::new_with_specifics(refresh_kind);
|
||||||
|
|
||||||
|
PtyProcessInfo {
|
||||||
|
system,
|
||||||
|
refresh_kind: process_refresh_kind,
|
||||||
|
pid_getter: ProcessIdGetter::new(pty),
|
||||||
|
current: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn refresh(&mut self) -> Option<&Process> {
|
||||||
|
let pid = self.pid_getter.pid()?;
|
||||||
|
self.system.refresh_processes_specifics(self.refresh_kind);
|
||||||
|
self.system.process(pid)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load(&mut self) -> Option<ProcessInfo> {
|
||||||
|
let process = self.refresh()?;
|
||||||
|
let cwd = process
|
||||||
|
.cwd()
|
||||||
|
.take()
|
||||||
|
.map_or(PathBuf::new(), |p| p.to_owned());
|
||||||
|
|
||||||
|
let info = ProcessInfo {
|
||||||
|
name: process.name().to_owned(),
|
||||||
|
cwd,
|
||||||
|
argv: process.cmd().to_vec(),
|
||||||
|
};
|
||||||
|
self.current = Some(info.clone());
|
||||||
|
Some(info)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Updates the cached process info, returns whether the Zed-relevant info has changed
|
||||||
|
pub fn has_changed(&mut self) -> bool {
|
||||||
|
let current = self.load();
|
||||||
|
let has_changed = match (self.current.as_ref(), current.as_ref()) {
|
||||||
|
(None, None) => false,
|
||||||
|
(Some(prev), Some(now)) => prev.cwd != now.cwd || prev.name != now.name,
|
||||||
|
_ => true,
|
||||||
|
};
|
||||||
|
if has_changed {
|
||||||
|
self.current = current;
|
||||||
|
}
|
||||||
|
has_changed
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ pub mod mappings;
|
|||||||
|
|
||||||
pub use alacritty_terminal;
|
pub use alacritty_terminal;
|
||||||
|
|
||||||
|
mod pty_info;
|
||||||
pub mod terminal_settings;
|
pub mod terminal_settings;
|
||||||
|
|
||||||
use alacritty_terminal::{
|
use alacritty_terminal::{
|
||||||
@ -34,18 +35,14 @@ use mappings::mouse::{
|
|||||||
|
|
||||||
use collections::{HashMap, VecDeque};
|
use collections::{HashMap, VecDeque};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use procinfo::LocalProcessInfo;
|
use pty_info::PtyProcessInfo;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use smol::channel::{Receiver, Sender};
|
use smol::channel::{Receiver, Sender};
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use std::num::NonZeroU32;
|
|
||||||
use task::TaskId;
|
use task::TaskId;
|
||||||
use terminal_settings::{AlternateScroll, Shell, TerminalBlink, TerminalSettings};
|
use terminal_settings::{AlternateScroll, Shell, TerminalBlink, TerminalSettings};
|
||||||
use theme::{ActiveTheme, Theme};
|
use theme::{ActiveTheme, Theme};
|
||||||
use util::truncate_and_trailoff;
|
use util::truncate_and_trailoff;
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use windows::Win32::{Foundation::HANDLE, System::Threading::GetProcessId};
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{self, min},
|
cmp::{self, min},
|
||||||
@ -57,9 +54,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
use std::os::unix::prelude::AsRawFd;
|
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, black, px, AnyWindowHandle, AppContext, Bounds, ClipboardItem, EventEmitter, Hsla,
|
actions, black, px, AnyWindowHandle, AppContext, Bounds, ClipboardItem, EventEmitter, Hsla,
|
||||||
Keystroke, ModelContext, Modifiers, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,
|
Keystroke, ModelContext, Modifiers, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,
|
||||||
@ -401,19 +395,7 @@ impl TerminalBuilder {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(unix)]
|
let pty_info = PtyProcessInfo::new(&pty);
|
||||||
let (fd, shell_pid) = (pty.file().as_raw_fd(), pty.child().id());
|
|
||||||
|
|
||||||
// todo("windows")
|
|
||||||
#[cfg(windows)]
|
|
||||||
let (fd, shell_pid) = {
|
|
||||||
let child = pty.child_watcher();
|
|
||||||
let handle = child.raw_handle();
|
|
||||||
let pid = child.pid().unwrap_or_else(|| unsafe {
|
|
||||||
NonZeroU32::new_unchecked(GetProcessId(HANDLE(handle)))
|
|
||||||
});
|
|
||||||
(handle, u32::from(pid))
|
|
||||||
};
|
|
||||||
|
|
||||||
//And connect them together
|
//And connect them together
|
||||||
let event_loop = EventLoop::new(
|
let event_loop = EventLoop::new(
|
||||||
@ -441,9 +423,7 @@ impl TerminalBuilder {
|
|||||||
last_mouse: None,
|
last_mouse: None,
|
||||||
matches: Vec::new(),
|
matches: Vec::new(),
|
||||||
selection_head: None,
|
selection_head: None,
|
||||||
shell_fd: fd as u32,
|
pty_info,
|
||||||
shell_pid,
|
|
||||||
foreground_process_info: None,
|
|
||||||
breadcrumb_text: String::new(),
|
breadcrumb_text: String::new(),
|
||||||
scroll_px: px(0.),
|
scroll_px: px(0.),
|
||||||
last_mouse_position: None,
|
last_mouse_position: None,
|
||||||
@ -598,9 +578,7 @@ pub struct Terminal {
|
|||||||
pub last_content: TerminalContent,
|
pub last_content: TerminalContent,
|
||||||
pub selection_head: Option<AlacPoint>,
|
pub selection_head: Option<AlacPoint>,
|
||||||
pub breadcrumb_text: String,
|
pub breadcrumb_text: String,
|
||||||
shell_pid: u32,
|
pub pty_info: PtyProcessInfo,
|
||||||
shell_fd: u32,
|
|
||||||
pub foreground_process_info: Option<LocalProcessInfo>,
|
|
||||||
scroll_px: Pixels,
|
scroll_px: Pixels,
|
||||||
next_link_id: usize,
|
next_link_id: usize,
|
||||||
selection_phase: SelectionPhase,
|
selection_phase: SelectionPhase,
|
||||||
@ -660,7 +638,7 @@ impl Terminal {
|
|||||||
AlacTermEvent::Wakeup => {
|
AlacTermEvent::Wakeup => {
|
||||||
cx.emit(Event::Wakeup);
|
cx.emit(Event::Wakeup);
|
||||||
|
|
||||||
if self.update_process_info() {
|
if self.pty_info.has_changed() {
|
||||||
cx.emit(Event::TitleChanged);
|
cx.emit(Event::TitleChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -675,56 +653,8 @@ impl Terminal {
|
|||||||
self.selection_phase == SelectionPhase::Selecting
|
self.selection_phase == SelectionPhase::Selecting
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the cached process info, returns whether the Zed-relevant info has changed
|
pub fn get_cwd(&self) -> Option<PathBuf> {
|
||||||
fn update_process_info(&mut self) -> bool {
|
self.pty_info.current.as_ref().map(|info| info.cwd.clone())
|
||||||
#[cfg(unix)]
|
|
||||||
let pid = {
|
|
||||||
let ret = unsafe { libc::tcgetpgrp(self.shell_fd as i32) };
|
|
||||||
if ret < 0 {
|
|
||||||
self.shell_pid as i32
|
|
||||||
} else {
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
let pid = {
|
|
||||||
let ret = unsafe { GetProcessId(HANDLE(self.shell_fd as _)) };
|
|
||||||
// the GetProcessId may fail and returns zero, which will lead to a stack overflow issue
|
|
||||||
if ret == 0 {
|
|
||||||
// in the builder process, there is a small chance, almost negligible,
|
|
||||||
// that this value could be zero, which means child_watcher returns None,
|
|
||||||
// GetProcessId returns 0.
|
|
||||||
if self.shell_pid == 0 {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
self.shell_pid
|
|
||||||
} else {
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
} as i32;
|
|
||||||
|
|
||||||
if let Some(process_info) = LocalProcessInfo::with_root_pid(pid as u32) {
|
|
||||||
let res = self
|
|
||||||
.foreground_process_info
|
|
||||||
.as_ref()
|
|
||||||
.map(|old_info| {
|
|
||||||
process_info.cwd != old_info.cwd || process_info.name != old_info.name
|
|
||||||
})
|
|
||||||
.unwrap_or(true);
|
|
||||||
|
|
||||||
self.foreground_process_info = Some(process_info.clone());
|
|
||||||
|
|
||||||
res
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_cwd(&self) -> Option<PathBuf> {
|
|
||||||
self.foreground_process_info
|
|
||||||
.as_ref()
|
|
||||||
.map(|info| info.cwd.clone())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///Takes events from Alacritty and translates them to behavior on this view
|
///Takes events from Alacritty and translates them to behavior on this view
|
||||||
@ -1402,7 +1332,8 @@ impl Terminal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => self
|
None => self
|
||||||
.foreground_process_info
|
.pty_info
|
||||||
|
.current
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|fpi| {
|
.map(|fpi| {
|
||||||
let process_file = fpi
|
let process_file = fpi
|
||||||
@ -1410,11 +1341,13 @@ impl Terminal {
|
|||||||
.file_name()
|
.file_name()
|
||||||
.map(|name| name.to_string_lossy().to_string())
|
.map(|name| name.to_string_lossy().to_string())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
let argv = fpi.argv.clone();
|
||||||
let process_name = format!(
|
let process_name = format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
fpi.name,
|
fpi.name,
|
||||||
if fpi.argv.len() >= 1 {
|
if argv.len() >= 1 {
|
||||||
format!(" {}", (fpi.argv[1..]).join(" "))
|
format!(" {}", (argv[1..]).join(" "))
|
||||||
} else {
|
} else {
|
||||||
"".to_string()
|
"".to_string()
|
||||||
}
|
}
|
||||||
|
@ -455,9 +455,7 @@ fn subscribe_for_terminal_events(
|
|||||||
cx.emit(ItemEvent::UpdateTab);
|
cx.emit(ItemEvent::UpdateTab);
|
||||||
let terminal = this.terminal().read(cx);
|
let terminal = this.terminal().read(cx);
|
||||||
if terminal.task().is_none() {
|
if terminal.task().is_none() {
|
||||||
if let Some(foreground_info) = &terminal.foreground_process_info {
|
if let Some(cwd) = terminal.get_cwd() {
|
||||||
let cwd = foreground_info.cwd.clone();
|
|
||||||
|
|
||||||
let item_id = cx.entity_id();
|
let item_id = cx.entity_id();
|
||||||
let workspace_id = this.workspace_id;
|
let workspace_id = this.workspace_id;
|
||||||
cx.background_executor()
|
cx.background_executor()
|
||||||
|
Loading…
Reference in New Issue
Block a user