@@ -75,17 +75,16 @@ fn open(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) ->
77fn buffer_close_by_ids_impl(
77fn buffer_close_by_ids_impl(
78− editor: &mut Editor,
78+ cx: &mut compositor::Context,
79 doc_ids: &[DocumentId],
79 doc_ids: &[DocumentId],
80 force: bool,
80 force: bool,
81) -> anyhow::Result<()> {
81) -> anyhow::Result<()> {
82− // TODO: deduplicate with ctx.block_try_flush_writes
82+ cx.block_try_flush_writes()?;
83− tokio::task::block_in_place(|| helix_lsp::block_on(editor.flush_writes()));
85 let (modified_ids, modified_names): (Vec<_>, Vec<_>) = doc_ids
84 let (modified_ids, modified_names): (Vec<_>, Vec<_>) = doc_ids
87 .filter_map(|&doc_id| {
86 .filter_map(|&doc_id| {
88− if let Err(CloseError::BufferModified(name)) = editor.close_document(doc_id, force) {
87+ if let Err(CloseError::BufferModified(name)) = cx.editor.close_document(doc_id, force) {
89 Some((doc_id, name))
88 Some((doc_id, name))
@@ -94,11 +93,11 @@ fn buffer_close_by_ids_impl(
96 if let Some(first) = modified_ids.first() {
95 if let Some(first) = modified_ids.first() {
97− let current = doc!(editor);
96+ let current = doc!(cx.editor);
98 // If the current document is unmodified, and there are modified
97 // If the current document is unmodified, and there are modified
99 // documents, switch focus to the first modified doc.
98 // documents, switch focus to the first modified doc.
100 if !modified_ids.contains(¤t.id()) {
99 if !modified_ids.contains(¤t.id()) {
101− editor.switch(*first, Action::Replace);
100+ cx.editor.switch(*first, Action::Replace);
104 "{} unsaved buffer(s) remaining: {:?}",
103 "{} unsaved buffer(s) remaining: {:?}",
@@ -157,7 +156,7 @@ fn buffer_close(
159 let document_ids = buffer_gather_paths_impl(cx.editor, args);
158 let document_ids = buffer_gather_paths_impl(cx.editor, args);
160− buffer_close_by_ids_impl(cx.editor, &document_ids, false)
159+ buffer_close_by_ids_impl(cx, &document_ids, false)
163fn force_buffer_close(
162fn force_buffer_close(
@@ -170,7 +169,7 @@ fn force_buffer_close(
172 let document_ids = buffer_gather_paths_impl(cx.editor, args);
171 let document_ids = buffer_gather_paths_impl(cx.editor, args);
173− buffer_close_by_ids_impl(cx.editor, &document_ids, true)
172+ buffer_close_by_ids_impl(cx, &document_ids, true)
176fn buffer_gather_others_impl(editor: &mut Editor) -> Vec<DocumentId> {
175fn buffer_gather_others_impl(editor: &mut Editor) -> Vec<DocumentId> {
@@ -192,7 +191,7 @@ fn buffer_close_others(
194 let document_ids = buffer_gather_others_impl(cx.editor);
193 let document_ids = buffer_gather_others_impl(cx.editor);
195− buffer_close_by_ids_impl(cx.editor, &document_ids, false)
194+ buffer_close_by_ids_impl(cx, &document_ids, false)
198fn force_buffer_close_others(
197fn force_buffer_close_others(
@@ -205,7 +204,7 @@ fn force_buffer_close_others(
207 let document_ids = buffer_gather_others_impl(cx.editor);
206 let document_ids = buffer_gather_others_impl(cx.editor);
208− buffer_close_by_ids_impl(cx.editor, &document_ids, true)
207+ buffer_close_by_ids_impl(cx, &document_ids, true)
211fn buffer_gather_all_impl(editor: &mut Editor) -> Vec<DocumentId> {
210fn buffer_gather_all_impl(editor: &mut Editor) -> Vec<DocumentId> {
@@ -222,7 +221,7 @@ fn buffer_close_all(
224 let document_ids = buffer_gather_all_impl(cx.editor);
223 let document_ids = buffer_gather_all_impl(cx.editor);
225− buffer_close_by_ids_impl(cx.editor, &document_ids, false)
224+ buffer_close_by_ids_impl(cx, &document_ids, false)
228fn force_buffer_close_all(
227fn force_buffer_close_all(
@@ -235,7 +234,7 @@ fn force_buffer_close_all(
237 let document_ids = buffer_gather_all_impl(cx.editor);
236 let document_ids = buffer_gather_all_impl(cx.editor);
238− buffer_close_by_ids_impl(cx.editor, &document_ids, true)
237+ buffer_close_by_ids_impl(cx, &document_ids, true)
241fn buffer_next(
240fn buffer_next(