From 936d91c378b82193c64842e3c2abeb867658d985 Mon Sep 17 00:00:00 2001 From: Grant Gilson Date: Wed, 22 Nov 2023 10:45:19 -0800 Subject: [PATCH] got a build --- Cargo.toml | 5 ++++- client/src/extension.ts | 2 ++ package.json | 6 ++++-- src/main.rs | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f535b01..3e42e4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ phf = { version = "0.11.1", features = ["macros"] } jwalk = "0.8.1" # home = "0.5.3" quit = "2.0.0" -psutil = "3.2.2" regex = "1.7.1" serde_json = "1.0.108" tantivy = "0.21.1" @@ -35,4 +34,8 @@ tantivy = "0.21.1" target = "x86_64-unknown-linux-gnu" [target.x86_64-unknown-linux-gnu] +psutil = "3.2.2" linker = "/usr/local/bin/x86_64-unknown-linux-gnu-gcc" + +[target.'cfg(windows)'.dependencies] +tasklist = "0.2.13" diff --git a/client/src/extension.ts b/client/src/extension.ts index 155feeb..26d2f8b 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -24,6 +24,8 @@ export async function activate(_context: ExtensionContext) { // Apple/Intel command = `${base_dir}/bin/fuzzy`; } + } else if ("windows") { + command = `${base_dir}/bin/fuzzy.exe`; } else { command = `${base_dir}/bin/fuzzy_x86_64-unknown-linux-gnu`; } diff --git a/package.json b/package.json index f439002..73071f5 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@types/glob": "^7.1.3", "@types/mocha": "^8.0.0", "@types/node": "^12.12.0", - "@types/vscode": "^1.44.0", + "@types/vscode": "^1.84.2", "@typescript-eslint/eslint-plugin": "^3.8.0", "@typescript-eslint/parser": "^3.8.0", "cross-env": "^7.0.2", @@ -97,6 +97,8 @@ "ts-loader": "^8.0.12", "typescript": "^4.4.3", "vscode-test": "^1.4.0", - "vscode-uri": "^3.0.2" + "vscode-uri": "^3.0.2", + "vscode": "^1.1.37", + "vscode-languageclient": "^9.0.1" } } diff --git a/src/main.rs b/src/main.rs index 10c750a..aef94c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod persistence; use persistence::Persistence; +use tasklist::tasklist; use std::sync::Arc; use tokio::sync::Mutex; @@ -40,6 +41,7 @@ impl LanguageServer for Backend { drop(persistence); tokio::spawn(async move { + #[cfg(not(target_family = "windows"))] loop { let editor_process_id = params.process_id.unwrap_or_else(|| quit::with_code(1)); @@ -55,6 +57,24 @@ impl LanguageServer for Backend { tokio::time::sleep(Duration::from_secs(60)).await; } + #[cfg(target_family = "Windows")] + loop { + use tasklist; + + let editor_process_id = params.process_id.unwrap_or_else(|| quit::with_code(1)); + + let editor_process_running = unsafe { + let mut tl = tasklist::Tasklist::new(); + tl.any(|process| process.get_pid() == editor_process_id) + }; + + if !editor_process_running { + quit::with_code(1); + } + + tokio::time::sleep(Duration::from_secs(60)).await; + } + }); let background_persistence = Arc::clone(&self.persistence);