From 1b5316ea74845a23bebf492dd091fd1fc3a8dcaa Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 30 Mar 2021 18:19:48 +0900 Subject: Track document modified state. --- helix-term/src/commands.rs | 2 +- helix-term/src/ui/editor.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 61c62251..8dc69544 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -830,7 +830,7 @@ pub fn command_mode(cx: &mut Context) { ["w"] | ["write"] => { // TODO: non-blocking via save() command let id = editor.view().doc; - let doc = &mut editor.document(id).unwrap(); + let doc = &mut editor.documents[id]; smol::block_on(doc.save()); } diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 1103d6f5..1f4bf6bd 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -415,14 +415,15 @@ impl EditorView { if let Some(path) = doc.relative_path() { let path = path.to_string_lossy(); + + let title = format!("{}{}", path, if doc.modified() { "[+]" } else { "" }); surface.set_stringn( viewport.x + 6, viewport.y, - path, + title, viewport.width.saturating_sub(6) as usize, text_color, ); - // TODO: append [+] if modified } surface.set_string( -- cgit v1.2.3-70-g09d2