Release RuneStone 0.1.4 with installable plugins and settings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
mod pty;
|
||||
mod plugins;
|
||||
mod workspace;
|
||||
|
||||
use pty::PtyState;
|
||||
@@ -12,6 +13,7 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.manage(WorkspaceState::new())
|
||||
.manage(PtyState::new())
|
||||
.manage(plugins::PluginState::default())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
workspace::workspace_open,
|
||||
workspace::workspace_open_window,
|
||||
@@ -30,6 +32,19 @@ pub fn run() {
|
||||
workspace::workspace_abs_path,
|
||||
workspace::workspace_reveal,
|
||||
workspace::workspace_search,
|
||||
plugins::plugins_snapshot,
|
||||
plugins::plugins_choose,
|
||||
plugins::plugins_cancel,
|
||||
plugins::plugins_install,
|
||||
plugins::plugins_set_enabled,
|
||||
plugins::plugins_load,
|
||||
plugins::plugins_release,
|
||||
plugins::plugins_prepare_remove,
|
||||
plugins::plugins_remove,
|
||||
plugins::plugins_retry_remove,
|
||||
plugins::plugins_reveal,
|
||||
plugins::plugins_data,
|
||||
plugins::plugins_asset,
|
||||
pty::pty_open,
|
||||
pty::pty_write,
|
||||
pty::pty_resize,
|
||||
@@ -43,6 +58,7 @@ pub fn run() {
|
||||
.run(|app, event| {
|
||||
if let tauri::RunEvent::WindowEvent { label, event: tauri::WindowEvent::Destroyed, .. } = &event {
|
||||
app.state::<PtyState>().close_window(label);
|
||||
app.state::<plugins::PluginState>().close_window(label);
|
||||
app.state::<WorkspaceState>().close_window(label);
|
||||
}
|
||||
if matches!(event, tauri::RunEvent::Exit) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+40
-13
@@ -456,7 +456,11 @@ pub fn workspace_open(
|
||||
#[tauri::command]
|
||||
pub fn workspace_list(window: tauri::Window, state: State<WorkspaceState>, rel: String) -> WsResult<Vec<TreeEntry>> {
|
||||
let root = current_root(&state, window.label())?;
|
||||
let dir = resolve_existing(&root, &rel)?;
|
||||
list_entries(&root, &rel)
|
||||
}
|
||||
|
||||
fn list_entries(root: &Path, rel: &str) -> WsResult<Vec<TreeEntry>> {
|
||||
let dir = resolve_existing(root, rel)?;
|
||||
if !dir.is_dir() {
|
||||
return Err(err("path is not a folder"));
|
||||
}
|
||||
@@ -464,12 +468,7 @@ pub fn workspace_list(window: tauri::Window, state: State<WorkspaceState>, rel:
|
||||
let mut entries = Vec::new();
|
||||
let walker = ignore::WalkBuilder::new(&dir)
|
||||
.max_depth(Some(1))
|
||||
.hidden(false)
|
||||
.git_ignore(true)
|
||||
.require_git(false)
|
||||
.git_global(true)
|
||||
.git_exclude(true)
|
||||
.parents(true)
|
||||
.standard_filters(false)
|
||||
.build();
|
||||
|
||||
for result in walker {
|
||||
@@ -788,17 +787,18 @@ pub struct SearchHit {
|
||||
|
||||
#[tauri::command]
|
||||
pub fn workspace_search(window: tauri::Window, state: State<WorkspaceState>, query: String) -> WsResult<Vec<SearchHit>> {
|
||||
let root = current_root(&state, window.label())?;
|
||||
search_entries(&root, &query)
|
||||
}
|
||||
|
||||
fn search_entries(root: &Path, query: &str) -> WsResult<Vec<SearchHit>> {
|
||||
let needle = query.trim().to_lowercase();
|
||||
if needle.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
let root = current_root(&state, window.label())?;
|
||||
let mut hits = Vec::new();
|
||||
let walker = ignore::WalkBuilder::new(&root)
|
||||
.hidden(false)
|
||||
.git_ignore(true)
|
||||
.require_git(false)
|
||||
.git_global(true)
|
||||
let walker = ignore::WalkBuilder::new(root)
|
||||
.standard_filters(false)
|
||||
.filter_entry(|entry| {
|
||||
entry.depth() == 0 || !is_internal_name(&entry.file_name().to_string_lossy())
|
||||
})
|
||||
@@ -887,6 +887,33 @@ mod tests {
|
||||
use super::*;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn ignore_files_do_not_hide_workspace_entries_or_search_results() {
|
||||
let fixture = std::env::temp_dir().join(format!("rs-ignore-rules-{}", std::process::id()));
|
||||
let root = fixture.join("workspace");
|
||||
fs::create_dir_all(root.join(".git/info")).unwrap();
|
||||
fs::write(fixture.join(".ignore"), "parent-excluded/\n").unwrap();
|
||||
fs::write(root.join(".gitignore"), "papers/\n").unwrap();
|
||||
fs::write(root.join(".ignore"), "local-excluded/\n").unwrap();
|
||||
fs::write(root.join(".git/info/exclude"), "git-excluded/\n").unwrap();
|
||||
for folder in ["papers", "local-excluded", "git-excluded", "parent-excluded", ".hidden-notes"] {
|
||||
fs::create_dir_all(root.join(folder)).unwrap();
|
||||
fs::write(root.join(folder).join("note.md"), "unique search phrase").unwrap();
|
||||
}
|
||||
fs::write(root.join("papers/.gitignore"), "note.md\n").unwrap();
|
||||
let root = dunce::canonicalize(root).unwrap();
|
||||
let entries = list_entries(&root, "").unwrap();
|
||||
let hits = search_entries(&root, "unique search phrase").unwrap();
|
||||
for folder in ["papers", "local-excluded", "git-excluded", "parent-excluded", ".hidden-notes"] {
|
||||
assert!(entries.iter().any(|entry| entry.rel_path == folder && entry.kind == "folder"), "{folder}");
|
||||
let note = format!("{folder}/note.md");
|
||||
assert!(list_entries(&root, folder).unwrap().iter().any(|entry| entry.rel_path == note), "{note}");
|
||||
assert!(hits.iter().any(|hit| hit.rel_path == note && hit.line == 1), "{note}");
|
||||
}
|
||||
assert!(!entries.iter().any(|entry| entry.name == ".git"));
|
||||
fs::remove_dir_all(fixture).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_keep_independent_roots_and_cleanup() {
|
||||
let state = WorkspaceState::new();
|
||||
|
||||
Reference in New Issue
Block a user