diff --git a/Cargo.lock b/Cargo.lock index 46cc8e017..29f49e28e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3138,7 +3138,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "steel-core" version = "0.6.0" -source = "git+https://github.com/mattwparas/steel.git#6237e35817e02fefdfd8dd2a54e584b677cb19c7" +source = "git+https://github.com/mattwparas/steel.git#d3110be47bf710af38e6c08fdd73c02a97bf20a9" dependencies = [ "abi_stable", "anyhow", @@ -3191,7 +3191,7 @@ dependencies = [ [[package]] name = "steel-derive" version = "0.5.0" -source = "git+https://github.com/mattwparas/steel.git#6237e35817e02fefdfd8dd2a54e584b677cb19c7" +source = "git+https://github.com/mattwparas/steel.git#d3110be47bf710af38e6c08fdd73c02a97bf20a9" dependencies = [ "proc-macro2", "quote", @@ -3201,7 +3201,7 @@ dependencies = [ [[package]] name = "steel-doc" version = "0.6.0" -source = "git+https://github.com/mattwparas/steel.git#6237e35817e02fefdfd8dd2a54e584b677cb19c7" +source = "git+https://github.com/mattwparas/steel.git#d3110be47bf710af38e6c08fdd73c02a97bf20a9" dependencies = [ "steel-core", ] @@ -3209,7 +3209,7 @@ dependencies = [ [[package]] name = "steel-gen" version = "0.2.0" -source = "git+https://github.com/mattwparas/steel.git#6237e35817e02fefdfd8dd2a54e584b677cb19c7" +source = "git+https://github.com/mattwparas/steel.git#d3110be47bf710af38e6c08fdd73c02a97bf20a9" dependencies = [ "codegen", "serde", @@ -3218,7 +3218,7 @@ dependencies = [ [[package]] name = "steel-parser" version = "0.6.0" -source = "git+https://github.com/mattwparas/steel.git#6237e35817e02fefdfd8dd2a54e584b677cb19c7" +source = "git+https://github.com/mattwparas/steel.git#d3110be47bf710af38e6c08fdd73c02a97bf20a9" dependencies = [ "compact_str", "fxhash", diff --git a/helix-term/src/commands/engine/steel.rs b/helix-term/src/commands/engine/steel.rs index a628797fa..ed1758c68 100644 --- a/helix-term/src/commands/engine/steel.rs +++ b/helix-term/src/commands/engine/steel.rs @@ -43,10 +43,9 @@ use std::{ borrow::Cow, collections::HashMap, error::Error, - ops::Deref, path::PathBuf, sync::{atomic::AtomicBool, Mutex, MutexGuard, RwLock, RwLockReadGuard}, - time::Duration, + time::{Duration, SystemTime}, }; use std::{str::FromStr as _, sync::Arc}; @@ -1587,6 +1586,14 @@ Get the `Rect` associated with the currently focused buffer. module.register_fn("editor-doc-in-view?", cx_is_document_in_view); module.register_fn("set-scratch-buffer-name!", set_scratch_buffer_name); + // Get the last saved time of the document + module.register_fn( + "editor-document-last-saved", + |cx: &mut Context, doc: DocumentId| -> Option { + cx.editor.documents.get(&doc).map(|x| x.last_saved_time()) + }, + ); + module.register_fn("set-buffer-uri!", set_buffer_uri); module.register_fn("editor-doc-exists?", cx_document_exists); @@ -1667,6 +1674,12 @@ Get the `Rect` associated with the currently focused buffer. // TODO: Lift this up template_function_arity_1("set-buffer-uri!", "Set the URI of the buffer"); template_function_arity_1("editor-doc-exists?", "Check if a document exists."); + + template_function_arity_1( + "editor-document-last-saved", + "Check when a document was last saved (returns a `SystemTime`)", + ); + 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( diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index c0472ad34..390e4ebef 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1155,6 +1155,10 @@ impl Document { } } + pub fn last_saved_time(&self) -> SystemTime { + self.last_saved_time + } + pub fn pickup_last_saved_time(&mut self) { self.last_saved_time = match self.path() { Some(path) => match path.metadata() { diff --git a/steel b/steel index 6237e3581..d3110be47 160000 --- a/steel +++ b/steel @@ -1 +1 @@ -Subproject commit 6237e35817e02fefdfd8dd2a54e584b677cb19c7 +Subproject commit d3110be47bf710af38e6c08fdd73c02a97bf20a9