feat(files): add CodeMirror 6 editor with save, dirty tracking, and 15 language modes
This commit is contained in:
parent
0ffbd93b8b
commit
3bb972fc01
6 changed files with 941 additions and 75 deletions
|
|
@ -566,6 +566,19 @@ fn read_file_content(path: String) -> Result<FileContent, String> {
|
|||
Ok(FileContent::Text { content, lang })
|
||||
}
|
||||
|
||||
// --- Write file ---
|
||||
|
||||
#[tauri::command]
|
||||
fn write_file_content(path: String, content: String) -> Result<(), String> {
|
||||
let file_path = std::path::Path::new(&path);
|
||||
// Safety: only write to existing files (no arbitrary path creation)
|
||||
if !file_path.is_file() {
|
||||
return Err(format!("Not an existing file: {path}"));
|
||||
}
|
||||
std::fs::write(&path, content.as_bytes())
|
||||
.map_err(|e| format!("Failed to write file: {e}"))
|
||||
}
|
||||
|
||||
// Directory picker: custom rfd command with parent window for modal behavior on Linux
|
||||
#[tauri::command]
|
||||
async fn pick_directory(window: tauri::Window) -> Result<Option<String>, String> {
|
||||
|
|
@ -743,6 +756,7 @@ pub fn run() {
|
|||
discover_markdown_files,
|
||||
list_directory_children,
|
||||
read_file_content,
|
||||
write_file_content,
|
||||
agent_messages_save,
|
||||
agent_messages_load,
|
||||
project_agent_state_save,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue