@@ -7,7 +7,7 @@ use crate::{
77 input:: { Event , InputOptions , KeyBindings } ,
88 module:: { ExitStatus , Module , State } ,
99 process:: Results ,
10- todo_file:: TodoFile ,
10+ todo_file:: { TodoFile , State as TodoFileState } ,
1111 view:: { RenderContext , ViewData } ,
1212} ;
1313
@@ -34,7 +34,10 @@ impl Module for ConfirmAbort {
3434 let mut results = Results :: new ( ) ;
3535 match confirmed {
3636 Confirmed :: Yes => {
37- self . todo_file . lock ( ) . set_lines ( vec ! [ ] ) ;
37+ let todo_state = self . todo_file . lock ( ) . state ( ) . clone ( ) ;
38+ if todo_state != TodoFileState :: Edit {
39+ self . todo_file . lock ( ) . set_lines ( vec ! [ ] ) ;
40+ }
3841 results. exit_status ( ExitStatus :: Good ) ;
3942 } ,
4043 Confirmed :: No => {
@@ -135,4 +138,24 @@ mod tests {
135138 } ,
136139 ) ;
137140 }
141+
142+ #[ test]
143+ fn handle_event_yes_in_edit ( ) {
144+ module_test (
145+ & [ "pick aaa comment" ] ,
146+ & [ Event :: from ( MetaEvent :: Yes ) ] ,
147+ |mut test_context| {
148+ let mut todo_file = test_context. take_todo_file ( ) ;
149+ todo_file. set_state ( TodoFileState :: Edit ) ;
150+
151+ let mut module = create_confirm_abort ( todo_file) ;
152+ assert_results ! (
153+ test_context. handle_event( & mut module) ,
154+ Artifact :: Event ( Event :: from( MetaEvent :: Yes ) ) ,
155+ Artifact :: ExitStatus ( ExitStatus :: Good )
156+ ) ;
157+ assert ! ( !module. todo_file. lock( ) . is_empty( ) ) ;
158+ } ,
159+ ) ;
160+ }
138161}
0 commit comments