Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/edit/src/bin/edit/draw_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ pub fn draw_handle_save(ctx: &mut Context, state: &mut State) {
if doc.path.is_some() {
if let Err(err) = doc.save(None) {
error_log_add(ctx, state, err);
// Don't keep trying to close the document (or exit) if it couldn't be saved.
state.wants_exit = false;
state.wants_close = false;
}
} else {
// No path? Show the file picker.
Expand Down
4 changes: 4 additions & 0 deletions crates/edit/src/bin/edit/draw_filepicker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ pub fn draw_file_picker(ctx: &mut Context, state: &mut State) {
}
}
if ctx.modal_end() {
// Cancelling the picker also cancels closing the document (or exiting) if we're
// here because the unsaved changes dialog asked to save it first.
state.wants_exit = false;
state.wants_close = false;
done = true;
}

Expand Down
3 changes: 2 additions & 1 deletion crates/edit/src/bin/edit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ fn draw(tui: &mut Tui, input: Option<input::Input>, state: &mut State) {
draw_editor(ctx, state);
draw_statusbar(ctx, state);

if state.wants_close {
// While the document is being saved via the file picker, hide the unsaved changes dialog.
if state.wants_close && state.wants_file_picker == StateFilePicker::None {
draw_handle_wants_close(ctx, state);
}
if state.wants_exit {
Expand Down