aboutsummaryrefslogtreecommitdiffstats
path: root/default-plugins/strider/src/main.rs
diff options
context:
space:
mode:
authordivens <divens@users.noreply.github.com>2026-03-21 19:20:32 +0100
committerGitHub <noreply@github.com>2026-03-21 19:20:32 +0100
commit3fa7744906d5704bdec771c74829841bd06cf7fc (patch)
tree6c4f0bd64c2e6087ce069a466cca942f4669f513 /default-plugins/strider/src/main.rs
parentRelease notes and fixes (#4879) (diff)
downloadsl0ppij-3fa7744906d5704bdec771c74829841bd06cf7fc.tar.gz
sl0ppij-3fa7744906d5704bdec771c74829841bd06cf7fc.tar.xz
sl0ppij-3fa7744906d5704bdec771c74829841bd06cf7fc.zip
Add windows support in strider (#4854)
* Add Windows path support to strider plugin Strider is a WASM plugin where std::path::PathBuf uses Unix semantics, so Windows backslash paths break parent(), join(), strip_prefix(), etc. Fix by normalizing all incoming paths to forward slashes at plugin boundaries and converting back to native backslashes for display. A new platform.rs module detects the host OS at runtime from the initial_cwd format and centralizes all platform-aware logic. Also fix scan_host_folder on the server side: canonicalize plugin_host_folder so the starts_with security check works on Windows, where canonicalize() adds the \?\ prefix. * Add virtual root view for drive and WSL navigation in strider On Windows, navigating up from a drive root (e.g. C:\) now shows a "Computer" view listing all available drives and WSL distributions. Drives are enumerated via GetLogicalDriveStringsW and WSL distros via `wsl -l -q` (since read_dir on \wsl.localhost fails with OS error 64/67). Drive letters appear before WSL entries, which are displayed as "Ubuntu-24.04 (WSL)" etc. On non-Windows platforms, behavior is unchanged. * Rename ListHostEntries to ListWindowsVolumes and gate behind FullHdAccess The old name was misleading — on Unix it just returned `/`, which isn't "listing host entries." Rename to ListWindowsVolumes to make the Windows-specific intent explicit, gate behind FullHdAccess permission, and replace the Unix implementation with a log::error since the command is not meaningful on non-Windows platforms. * Replace direct array indexing with .get() in strider platform detection Use safe accessors and matches! macro instead of direct byte indexing for bounds-checked access patterns. --------- Co-authored-by: divens <divens.dev@gmail.com>
Diffstat (limited to 'default-plugins/strider/src/main.rs')
-rw-r--r--default-plugins/strider/src/main.rs53
1 files changed, 38 insertions, 15 deletions
diff --git a/default-plugins/strider/src/main.rs b/default-plugins/strider/src/main.rs
index 14571532..02ae6a95 100644
--- a/default-plugins/strider/src/main.rs
+++ b/default-plugins/strider/src/main.rs
@@ -1,9 +1,13 @@
mod file_list_view;
+mod platform;
mod search_view;
mod shared;
mod state;
-use shared::{render_current_path, render_instruction_line, render_search_term};
+use platform::Platform;
+use shared::{
+ render_current_path, render_instruction_line, render_search_term, render_virtual_root_header,
+};
use state::{refresh_directory, State};
use std::collections::BTreeMap;
use std::path::PathBuf;
@@ -14,7 +18,12 @@ register_plugin!(State);
impl ZellijPlugin for State {
fn load(&mut self, configuration: BTreeMap<String, String>) {
let plugin_ids = get_plugin_ids();
- self.initial_cwd = plugin_ids.initial_cwd;
+ let initial_cwd_str = plugin_ids.initial_cwd.to_string_lossy().to_string();
+ let platform = Platform::detect(&initial_cwd_str);
+ self.platform = platform;
+ self.initial_cwd = Platform::normalize(&plugin_ids.initial_cwd);
+ self.file_list_view.platform = platform;
+ self.search_view.platform = platform;
let show_hidden_files = configuration
.get("show_hidden_files")
.map(|v| v == "true")
@@ -35,7 +44,10 @@ impl ZellijPlugin for State {
]);
self.file_list_view.clear_selected();
- match configuration.get("caller_cwd").map(|c| PathBuf::from(c)) {
+ match configuration
+ .get("caller_cwd")
+ .map(|c| Platform::normalize(&PathBuf::from(c)))
+ {
Some(caller_cwd) => {
self.file_list_view.path = caller_cwd;
},
@@ -71,7 +83,9 @@ impl ZellijPlugin for State {
should_render = true;
},
BareKey::Esc if key.has_no_modifiers() => {
- if self.is_searching {
+ if self.is_in_virtual_root {
+ self.exit_virtual_root();
+ } else if self.is_searching {
self.clear_search_term();
} else {
self.file_list_view.clear_selected();
@@ -98,7 +112,9 @@ impl ZellijPlugin for State {
should_render = true;
},
BareKey::Left if key.has_no_modifiers() => {
- self.descend_to_previous_path();
+ if !self.is_in_virtual_root {
+ self.descend_to_previous_path();
+ }
should_render = true;
},
BareKey::Char('e') if key.has_modifiers(&[KeyModifier::Ctrl]) => {
@@ -167,17 +183,24 @@ impl ZellijPlugin for State {
fn render(&mut self, rows: usize, cols: usize) {
self.current_rows = Some(rows);
let rows_for_list = rows.saturating_sub(6);
- render_search_term(&self.search_term);
- render_current_path(
- &self.file_list_view.path,
- self.file_list_view.path_is_dir,
- self.handling_filepick_request_from.is_some(),
- cols,
- );
- if self.is_searching {
- self.search_view.render(rows_for_list, cols);
+ if self.is_in_virtual_root {
+ render_search_term("");
+ render_virtual_root_header(cols);
+ self.render_virtual_root(rows_for_list, cols);
} else {
- self.file_list_view.render(rows_for_list, cols);
+ render_search_term(&self.search_term);
+ render_current_path(
+ &self.file_list_view.path,
+ self.file_list_view.path_is_dir,
+ self.handling_filepick_request_from.is_some(),
+ cols,
+ self.platform,
+ );
+ if self.is_searching {
+ self.search_view.render(rows_for_list, cols);
+ } else {
+ self.file_list_view.render(rows_for_list, cols);
+ }
}
render_instruction_line(rows, cols);
}