File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -416,8 +416,12 @@ fn write_quit(
416
416
event : PromptEvent ,
417
417
) -> anyhow:: Result < ( ) > {
418
418
write_impl ( cx, args. first ( ) , false ) ?;
419
- // TODO: change to use document close
420
- helix_lsp:: block_on ( cx. jobs . finish ( ) ) ?;
419
+ let doc = doc_mut ! ( cx. editor) ;
420
+
421
+ tokio:: task:: block_in_place ( || helix_lsp:: block_on ( doc. try_flush_saves ( ) ) )
422
+ . map ( |result| result. map ( |_| ( ) ) )
423
+ . unwrap_or ( Ok ( ( ) ) ) ?;
424
+
421
425
quit ( cx, & [ ] , event)
422
426
}
423
427
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use helix_term::application::Application;
8
8
9
9
use super :: * ;
10
10
11
- #[ tokio:: test]
11
+ #[ tokio:: test( flavor = "multi_thread" ) ]
12
12
async fn test_write_quit_fail ( ) -> anyhow:: Result < ( ) > {
13
13
let file = helpers:: new_readonly_tempfile ( ) ?;
14
14
@@ -22,6 +22,11 @@ async fn test_write_quit_fail() -> anyhow::Result<()> {
22
22
) ?,
23
23
Some ( "ihello<esc>:wq<ret>" ) ,
24
24
Some ( & |app| {
25
+ let mut docs: Vec < _ > = app. editor . documents ( ) . collect ( ) ;
26
+ assert_eq ! ( 1 , docs. len( ) ) ;
27
+
28
+ let doc = docs. pop ( ) . unwrap ( ) ;
29
+ assert_eq ! ( Some ( file. path( ) ) , doc. path( ) . map( PathBuf :: as_path) ) ;
25
30
assert_eq ! ( & Severity :: Error , app. editor. get_status( ) . unwrap( ) . 1 ) ;
26
31
} ) ,
27
32
)
Original file line number Diff line number Diff line change @@ -787,6 +787,19 @@ impl Editor {
787
787
Ok ( id)
788
788
}
789
789
790
+ /// Closes every document and view, which will ultimately shut down the app.
791
+ // pub async fn close(&mut self) -> anyhow::Result<()> {
792
+ // let docs: Vec<_> = self.documents().map(|doc| doc.id()).collect();
793
+
794
+ // // closing all documents also closes all views, which will shut
795
+ // // down the app
796
+ // for doc in docs {
797
+ // self.close_document(doc, false).await?;
798
+ // }
799
+
800
+ // Ok(())
801
+ // }
802
+
790
803
pub fn close ( & mut self , id : ViewId ) {
791
804
let view = self . tree . get ( self . tree . focus ) ;
792
805
// remove selection
You can’t perform that action at this time.
0 commit comments