only quit if changes are saved

This commit is contained in:
alice pellerin
2026-03-18 19:25:48 -05:00
parent a699c0a371
commit 2ee61fef71
3 changed files with 16 additions and 4 deletions
+10
View File
@@ -4,6 +4,7 @@ use crate::{BYTES_PER_LINE, app::{App, Mode, PartialAction}, edit_action::EditAc
#[derive(Clone, Copy)]
pub enum Action {
QuitIfSaved,
Quit,
NormalMode,
@@ -62,6 +63,7 @@ pub enum Action {
impl App {
pub fn execute(&mut self, action: Action) {
match action {
Action::QuitIfSaved => self.quit_if_saved(),
Action::Quit => self.quit(),
Action::NormalMode => self.normal_mode(),
@@ -118,6 +120,14 @@ impl App {
}
}
const fn quit_if_saved(&mut self) {
if self.all_changes_saved() {
self.quit();
} else {
// TODO: show alert of some kind
}
}
const fn quit(&mut self) {
self.should_quit = true;
}