mirror of https://github.com/lapce/lapce.git
fix: build WSL backend only for Windows (#2166)
This commit is contained in:
parent
5ee7ede0bb
commit
f55be6c2a1
|
@ -116,8 +116,9 @@ pub fn is_palette_command(&self) -> bool {
|
|||
| LapceWorkbenchCommand::ChangeColorTheme
|
||||
| LapceWorkbenchCommand::ChangeIconTheme
|
||||
| LapceWorkbenchCommand::ConnectSshHost
|
||||
| LapceWorkbenchCommand::ConnectWsl
|
||||
| LapceWorkbenchCommand::PaletteWorkspace => return true,
|
||||
#[cfg(windows)]
|
||||
LapceWorkbenchCommand::ConnectWsl => return true,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -322,6 +323,7 @@ pub enum LapceWorkbenchCommand {
|
|||
#[strum(message = "Connect to SSH Host")]
|
||||
ConnectSshHost,
|
||||
|
||||
#[cfg(windows)]
|
||||
#[strum(serialize = "connect_wsl")]
|
||||
#[strum(message = "Connect to WSL")]
|
||||
ConnectWsl,
|
||||
|
|
|
@ -1163,6 +1163,7 @@ fn merge_config(
|
|||
}
|
||||
}
|
||||
LapceWorkspaceType::RemoteSSH(_) => {}
|
||||
#[cfg(windows)]
|
||||
LapceWorkspaceType::RemoteWSL => {}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ pub fn load(
|
|||
.map(|i| (i.size, i.pos))
|
||||
.unwrap_or_else(|_| (Size::new(800.0, 600.0), Point::new(0.0, 0.0)));
|
||||
for dir in dirs {
|
||||
#[cfg(target_os = "windows")]
|
||||
#[cfg(windows)]
|
||||
let workspace_type =
|
||||
if !env::var("WSL_DISTRO_NAME").unwrap_or_default().is_empty()
|
||||
|| !env::var("WSL_INTEROP").unwrap_or_default().is_empty()
|
||||
|
@ -151,7 +151,7 @@ pub fn load(
|
|||
LapceWorkspaceType::Local
|
||||
};
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[cfg(not(windows))]
|
||||
let workspace_type = LapceWorkspaceType::Local;
|
||||
|
||||
let info = WindowInfo {
|
||||
|
@ -1827,6 +1827,7 @@ pub fn run_workbench_command(
|
|||
Target::Widget(self.palette.widget_id),
|
||||
));
|
||||
}
|
||||
#[cfg(windows)]
|
||||
LapceWorkbenchCommand::ConnectWsl => ctx.submit_command(Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::SetWorkspace(LapceWorkspace {
|
||||
|
@ -4585,16 +4586,23 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|||
pub enum LapceWorkspaceType {
|
||||
Local,
|
||||
RemoteSSH(SshHost),
|
||||
#[cfg(windows)]
|
||||
RemoteWSL,
|
||||
}
|
||||
|
||||
impl LapceWorkspaceType {
|
||||
#[cfg(windows)]
|
||||
pub fn is_remote(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
LapceWorkspaceType::RemoteSSH(_) | LapceWorkspaceType::RemoteWSL
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn is_remote(&self) -> bool {
|
||||
matches!(self, LapceWorkspaceType::RemoteSSH(_))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for LapceWorkspaceType {
|
||||
|
@ -4604,6 +4612,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|||
LapceWorkspaceType::RemoteSSH(ssh) => {
|
||||
write!(f, "ssh://{ssh}")
|
||||
}
|
||||
#[cfg(windows)]
|
||||
LapceWorkspaceType::RemoteWSL => f.write_str("WSL"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -939,6 +939,7 @@ fn get_workspaces(&mut self, _ctx: &mut EventCtx) {
|
|||
LapceWorkspaceType::RemoteSSH(ssh) => {
|
||||
format!("[{ssh}] {text}")
|
||||
}
|
||||
#[cfg(windows)]
|
||||
LapceWorkspaceType::RemoteWSL => {
|
||||
format!("[wsl] {text}")
|
||||
}
|
||||
|
|
|
@ -379,6 +379,7 @@ fn start(
|
|||
LapceWorkspaceType::RemoteSSH(ssh) => {
|
||||
self.start_remote(SshRemote { ssh })?;
|
||||
}
|
||||
#[cfg(windows)]
|
||||
LapceWorkspaceType::RemoteWSL => {
|
||||
let distro = WslDistro::all()?
|
||||
.into_iter()
|
||||
|
@ -866,12 +867,14 @@ fn command_builder(&self) -> Command {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[derive(Debug)]
|
||||
struct WslDistro {
|
||||
pub name: String,
|
||||
pub default: bool,
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl WslDistro {
|
||||
fn all() -> Result<Vec<WslDistro>> {
|
||||
let cmd = new_command("wsl")
|
||||
|
@ -906,10 +909,12 @@ fn all() -> Result<Vec<WslDistro>> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
struct WslRemote {
|
||||
distro: String,
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl Remote for WslRemote {
|
||||
fn upload_file(&self, local: impl AsRef<Path>, remote: &str) -> Result<()> {
|
||||
let mut wsl_path = Path::new(r"\\wsl.localhost\").join(&self.distro);
|
||||
|
|
|
@ -602,6 +602,7 @@ fn paint(
|
|||
LapceWorkspaceType::RemoteSSH(ssh) => {
|
||||
format!("[{ssh}] {text}")
|
||||
}
|
||||
#[cfg(windows)]
|
||||
LapceWorkspaceType::RemoteWSL => {
|
||||
format!("[wsl] {text}")
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ fn workspace_title(workspace: &LapceWorkspace) -> Option<String> {
|
|||
Some(match &workspace.kind {
|
||||
LapceWorkspaceType::Local => format!("{dir}"),
|
||||
LapceWorkspaceType::RemoteSSH(ssh) => format!("{dir} [{ssh}]"),
|
||||
#[cfg(windows)]
|
||||
LapceWorkspaceType::RemoteWSL => format!("{dir} [wsl]"),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -167,19 +167,18 @@ fn update_remote(
|
|||
LapceWorkspaceType::Local => data
|
||||
.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_REMOTE_LOCAL),
|
||||
LapceWorkspaceType::RemoteSSH(_) | LapceWorkspaceType::RemoteWSL => {
|
||||
match *data.proxy_status {
|
||||
ProxyStatus::Connecting => data
|
||||
.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_REMOTE_CONNECTING),
|
||||
ProxyStatus::Connected => data
|
||||
.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_REMOTE_CONNECTED),
|
||||
ProxyStatus::Disconnected => data
|
||||
.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_REMOTE_DISCONNECTED),
|
||||
}
|
||||
}
|
||||
// LapceWorkspaceType::Remote*
|
||||
_ => match *data.proxy_status {
|
||||
ProxyStatus::Connecting => data
|
||||
.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_REMOTE_CONNECTING),
|
||||
ProxyStatus::Connected => data
|
||||
.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_REMOTE_CONNECTED),
|
||||
ProxyStatus::Disconnected => data
|
||||
.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_REMOTE_DISCONNECTED),
|
||||
},
|
||||
};
|
||||
self.rects.push((remote_rect, color.clone()));
|
||||
let remote_svg = data.config.ui_svg(LapceIcons::REMOTE);
|
||||
|
@ -529,6 +528,7 @@ fn update_folder(
|
|||
LapceWorkspaceType::RemoteSSH(ssh) => {
|
||||
format!(" [SSH: {}]", ssh.host)
|
||||
}
|
||||
#[cfg(windows)]
|
||||
LapceWorkspaceType::RemoteWSL => " [WSL]".to_string(),
|
||||
};
|
||||
let text = format!("{path}{remote}");
|
||||
|
|
Loading…
Reference in New Issue