diff --git a/crates/edit/src/bin/edit/draw_editor.rs b/crates/edit/src/bin/edit/draw_editor.rs index 3e4ce72c979..08ee0a3eb38 100644 --- a/crates/edit/src/bin/edit/draw_editor.rs +++ b/crates/edit/src/bin/edit/draw_editor.rs @@ -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. diff --git a/crates/edit/src/bin/edit/draw_filepicker.rs b/crates/edit/src/bin/edit/draw_filepicker.rs index 4576a7efaae..18d35e3d3ad 100644 --- a/crates/edit/src/bin/edit/draw_filepicker.rs +++ b/crates/edit/src/bin/edit/draw_filepicker.rs @@ -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; } diff --git a/crates/edit/src/bin/edit/main.rs b/crates/edit/src/bin/edit/main.rs index c1128c5b571..c8e53b7320e 100644 --- a/crates/edit/src/bin/edit/main.rs +++ b/crates/edit/src/bin/edit/main.rs @@ -345,7 +345,8 @@ fn draw(tui: &mut Tui, input: Option, 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 {