check if a document has been modified

pull/8675/head
Matt Paras 2025-05-31 10:07:13 -07:00
parent 01cfd2e6d4
commit bc01dda33a
1 changed files with 12 additions and 0 deletions

View File

@ -1594,6 +1594,13 @@ Get the `Rect` associated with the currently focused buffer.
},
);
module.register_fn(
"editor-document-dirty?",
|cx: &mut Context, doc: DocumentId| -> Option<bool> {
cx.editor.documents.get(&doc).map(|x| x.is_modified())
},
);
module.register_fn("set-buffer-uri!", set_buffer_uri);
module.register_fn("editor-doc-exists?", cx_document_exists);
@ -1680,6 +1687,11 @@ Get the `Rect` associated with the currently focused buffer.
"Check when a document was last saved (returns a `SystemTime`)",
);
template_function_arity_1(
"editor-document-dirty?",
"Check if a document has unsaved changes",
);
template_function_arity_1("editor->text", "Get the document as a rope.");
template_function_arity_1("editor-document->path", "Get the path to a document.");
template_function_arity_1(