mirror of https://github.com/lapce/lapce.git
proxy start at ssh
This commit is contained in:
parent
b9c1468389
commit
b2daa3e0ae
|
@ -1241,10 +1241,11 @@ pub fn select(
|
||||||
&PaletteType::Workspace => {
|
&PaletteType::Workspace => {
|
||||||
let state =
|
let state =
|
||||||
LAPCE_APP_STATE.get_tab_state(&self.window_id, &self.tab_id);
|
LAPCE_APP_STATE.get_tab_state(&self.window_id, &self.tab_id);
|
||||||
|
state.stop();
|
||||||
|
|
||||||
*state.workspace.lock() = self.workspace.clone().unwrap();
|
*state.workspace.lock() = self.workspace.clone().unwrap();
|
||||||
*state.ssh_session.lock() = None;
|
*state.ssh_session.lock() = None;
|
||||||
state.stop();
|
state.start_proxy();
|
||||||
state.start_plugin();
|
|
||||||
ctx.request_paint();
|
ctx.request_paint();
|
||||||
}
|
}
|
||||||
&PaletteType::Command => {
|
&PaletteType::Command => {
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
use crate::buffer::BufferId;
|
use crate::buffer::BufferId;
|
||||||
use crate::command::LapceUICommand;
|
use crate::command::LapceUICommand;
|
||||||
|
use crate::state::LapceWorkspace;
|
||||||
|
use crate::state::LapceWorkspaceType;
|
||||||
use crate::state::LAPCE_APP_STATE;
|
use crate::state::LAPCE_APP_STATE;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -81,6 +83,10 @@ pub fn get_completion(
|
||||||
f,
|
f,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn stop(&self) {
|
||||||
|
self.process.lock().kill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -161,13 +167,29 @@ fn handle_request(
|
||||||
pub fn start_proxy_process(
|
pub fn start_proxy_process(
|
||||||
window_id: WindowId,
|
window_id: WindowId,
|
||||||
tab_id: WidgetId,
|
tab_id: WidgetId,
|
||||||
workspace: PathBuf,
|
workspace: LapceWorkspace,
|
||||||
) {
|
) {
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let child = Command::new("/Users/Lulu/lapce/target/debug/lapce-proxy")
|
let workspace_type = LAPCE_APP_STATE
|
||||||
.stdin(Stdio::piped())
|
.get_tab_state(&window_id, &tab_id)
|
||||||
.stdout(Stdio::piped())
|
.workspace
|
||||||
.spawn();
|
.lock()
|
||||||
|
.kind
|
||||||
|
.clone();
|
||||||
|
let mut child = match workspace_type {
|
||||||
|
LapceWorkspaceType::Local => {
|
||||||
|
Command::new("/Users/Lulu/lapce/target/debug/lapce-proxy")
|
||||||
|
.stdin(Stdio::piped())
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
}
|
||||||
|
LapceWorkspaceType::RemoteSSH(user, host) => Command::new("ssh")
|
||||||
|
.arg(format!("{}@{}", user, host))
|
||||||
|
.arg("./lapce/lapce-proxy")
|
||||||
|
.stdin(Stdio::piped())
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.spawn(),
|
||||||
|
};
|
||||||
if child.is_err() {
|
if child.is_err() {
|
||||||
println!("can't start proxy {:?}", child);
|
println!("can't start proxy {:?}", child);
|
||||||
return;
|
return;
|
||||||
|
@ -181,7 +203,7 @@ pub fn start_proxy_process(
|
||||||
peer,
|
peer,
|
||||||
process: Arc::new(Mutex::new(child)),
|
process: Arc::new(Mutex::new(child)),
|
||||||
};
|
};
|
||||||
proxy.initialize(workspace);
|
proxy.initialize(workspace.path.clone());
|
||||||
{
|
{
|
||||||
let state = LAPCE_APP_STATE.get_tab_state(&window_id, &tab_id);
|
let state = LAPCE_APP_STATE.get_tab_state(&window_id, &tab_id);
|
||||||
*state.proxy.lock() = Some(proxy);
|
*state.proxy.lock() = Some(proxy);
|
||||||
|
|
|
@ -293,6 +293,7 @@ pub fn get_state(&self, tab_id: &WidgetId) -> LapceTabState {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LapceTabState {
|
pub struct LapceTabState {
|
||||||
|
pub window_id: WindowId,
|
||||||
pub tab_id: WidgetId,
|
pub tab_id: WidgetId,
|
||||||
pub status_id: WidgetId,
|
pub status_id: WidgetId,
|
||||||
pub workspace: Arc<Mutex<LapceWorkspace>>,
|
pub workspace: Arc<Mutex<LapceWorkspace>>,
|
||||||
|
@ -321,6 +322,7 @@ pub fn new(window_id: WindowId) -> LapceTabState {
|
||||||
let tab_id = WidgetId::next();
|
let tab_id = WidgetId::next();
|
||||||
let status_id = WidgetId::next();
|
let status_id = WidgetId::next();
|
||||||
let state = LapceTabState {
|
let state = LapceTabState {
|
||||||
|
window_id,
|
||||||
tab_id: tab_id.clone(),
|
tab_id: tab_id.clone(),
|
||||||
status_id,
|
status_id,
|
||||||
workspace: Arc::new(Mutex::new(workspace.clone())),
|
workspace: Arc::new(Mutex::new(workspace.clone())),
|
||||||
|
@ -350,7 +352,7 @@ pub fn new(window_id: WindowId) -> LapceTabState {
|
||||||
ssh_session: Arc::new(Mutex::new(None)),
|
ssh_session: Arc::new(Mutex::new(None)),
|
||||||
proxy: Arc::new(Mutex::new(None)),
|
proxy: Arc::new(Mutex::new(None)),
|
||||||
};
|
};
|
||||||
start_proxy_process(window_id, tab_id, workspace.path.clone());
|
start_proxy_process(window_id, tab_id, workspace.clone());
|
||||||
let local_state = state.clone();
|
let local_state = state.clone();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
local_state.start_plugin();
|
local_state.start_plugin();
|
||||||
|
@ -358,9 +360,16 @@ pub fn new(window_id: WindowId) -> LapceTabState {
|
||||||
state
|
state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn start_proxy(&self) {
|
||||||
|
start_proxy_process(
|
||||||
|
self.window_id,
|
||||||
|
self.tab_id,
|
||||||
|
self.workspace.lock().clone(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn stop(&self) {
|
pub fn stop(&self) {
|
||||||
self.plugins.lock().stop();
|
self.proxy.lock().as_ref().unwrap().stop();
|
||||||
self.lsp.lock().stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_plugin(&self) {
|
pub fn start_plugin(&self) {
|
||||||
|
|
Loading…
Reference in New Issue