From bc01dda33a7bd2a8df35fb994ad1320f9856c7cd Mon Sep 17 00:00:00 2001 From: Matt Paras Date: Sat, 31 May 2025 10:07:13 -0700 Subject: [PATCH] check if a document has been modified --- helix-term/src/commands/engine/steel.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/helix-term/src/commands/engine/steel.rs b/helix-term/src/commands/engine/steel.rs index ed1758c68..3ee81d830 100644 --- a/helix-term/src/commands/engine/steel.rs +++ b/helix-term/src/commands/engine/steel.rs @@ -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 { + 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(