@@ -8,7 +8,12 @@ use dua::{
88 WalkOptions , WalkResult ,
99} ;
1010use failure:: Error ;
11- use std:: { collections:: BTreeMap , io, path:: PathBuf } ;
11+ use std:: {
12+ collections:: BTreeMap ,
13+ io,
14+ path:: PathBuf ,
15+ io:: Write
16+ } ;
1217use termion:: event:: Key ;
1318use tui:: backend:: Backend ;
1419use tui_react:: Terminal ;
@@ -72,7 +77,7 @@ impl TerminalApp {
7277 }
7378 pub fn process_events < B > (
7479 & mut self ,
75- terminal : & mut Terminal < B > ,
80+ mut terminal : Terminal < B > ,
7681 keys : impl Iterator < Item = Result < Key , io:: Error > > ,
7782 ) -> Result < WalkResult , Error >
7883 where
@@ -81,7 +86,7 @@ impl TerminalApp {
8186 use termion:: event:: Key :: * ;
8287 use FocussedPane :: * ;
8388
84- self . draw ( terminal) ?;
89+ self . draw ( & mut terminal) ?;
8590 for key in keys. filter_map ( Result :: ok) {
8691 self . update_message ( ) ;
8792 match key {
@@ -91,7 +96,13 @@ impl TerminalApp {
9196 }
9297 Ctrl ( 'c' ) => break ,
9398 Char ( 'q' ) | Esc => match self . state . focussed {
94- Main => break ,
99+ Main => {
100+ drop ( terminal) ;
101+ io:: stdout ( ) . flush ( ) . ok ( ) ;
102+ // Exit 'quickly' to avoid having to wait for all memory to be freed by us.
103+ // Let the OS do it - we have nothing to lose, literally.
104+ std:: process:: exit ( 0 ) ;
105+ } ,
95106 Mark => self . state . focussed = Main ,
96107 Help => {
97108 self . state . focussed = Main ;
@@ -102,7 +113,7 @@ impl TerminalApp {
102113 }
103114
104115 match self . state . focussed {
105- FocussedPane :: Mark => self . dispatch_to_mark_pane ( key, terminal) ,
116+ FocussedPane :: Mark => self . dispatch_to_mark_pane ( key, & mut terminal) ,
106117 FocussedPane :: Help => {
107118 self . window . help_pane . as_mut ( ) . expect ( "help pane" ) . key ( key) ;
108119 }
@@ -121,7 +132,7 @@ impl TerminalApp {
121132 _ => { }
122133 } ,
123134 } ;
124- self . draw ( terminal) ?;
135+ self . draw ( & mut terminal) ?;
125136 }
126137 Ok ( WalkResult {
127138 num_errors : self . traversal . io_errors ,
0 commit comments