feat: add built-in file editor with syntax highlighting
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 58s
CI / Lint & Test (pull_request) Successful in 16m9s
CI / Build Linux (pull_request) Successful in 21m21s
CI / Build Windows (cross-compile) (pull_request) Successful in 34m43s

- Add CodeMirror 6 editor with support for 40+ languages
- Add file browser sidebar with directory tree navigation
- Add multi-tab support with dirty state indicators
- Add keyboard shortcuts (Ctrl+E, Ctrl+B, Ctrl+S, Ctrl+W)
- Add editor toggle button to status bar
- Editor uses current session's CWD and requires connection
- Add Tauri commands for file operations (list, read, write)
This commit is contained in:
2026-01-28 16:12:51 -08:00
committed by Naomi Carrigan
parent edc863e020
commit 392243f54f
14 changed files with 2015 additions and 3 deletions
+69
View File
@@ -394,6 +394,75 @@ pub async fn get_file_size(file_path: String) -> Result<u64, String> {
Ok(metadata.len())
}
// ==================== Editor File Operations ====================
#[derive(Debug, Clone, serde::Serialize)]
pub struct FileEntry {
pub name: String,
pub path: String,
#[serde(rename = "isDirectory")]
pub is_directory: bool,
}
#[tauri::command]
pub async fn list_directory(path: String) -> Result<Vec<FileEntry>, String> {
use std::fs;
use std::path::Path;
let dir_path = Path::new(&path);
if !dir_path.exists() {
return Err(format!("Directory does not exist: {}", path));
}
if !dir_path.is_dir() {
return Err(format!("Path is not a directory: {}", path));
}
let entries = fs::read_dir(dir_path)
.map_err(|e| format!("Failed to read directory: {}", e))?;
let mut file_entries = Vec::new();
for entry in entries {
let entry = entry.map_err(|e| format!("Failed to read entry: {}", e))?;
let path = entry.path();
let name = entry
.file_name()
.to_string_lossy()
.to_string();
// Skip hidden files by default (can be made configurable later)
if name.starts_with('.') {
continue;
}
file_entries.push(FileEntry {
name,
path: path.to_string_lossy().to_string(),
is_directory: path.is_dir(),
});
}
Ok(file_entries)
}
#[tauri::command]
pub async fn read_file_content(path: String) -> Result<String, String> {
use std::fs;
fs::read_to_string(&path)
.map_err(|e| format!("Failed to read file: {}", e))
}
#[tauri::command]
pub async fn write_file_content(path: String, content: String) -> Result<(), String> {
use std::fs;
fs::write(&path, content)
.map_err(|e| format!("Failed to write file: {}", e))
}
#[cfg(test)]
mod tests {
use super::*;
+3
View File
@@ -151,6 +151,9 @@ pub fn run() {
search_clipboard_entries,
get_clipboard_languages,
update_clipboard_language,
list_directory,
read_file_content,
write_file_content,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");