File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
core/src/modules/confirm_abort Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use std::sync::Arc;
22
33use input:: InputOptions ;
44use parking_lot:: Mutex ;
5- use todo_file:: TodoFile ;
5+ use todo_file:: { TodoFile , State as TodoFileState } ;
66use view:: { RenderContext , ViewData } ;
77
88use crate :: {
@@ -35,7 +35,10 @@ impl Module for ConfirmAbort {
3535 let mut results = Results :: new ( ) ;
3636 match confirmed {
3737 Confirmed :: Yes => {
38- self . todo_file . lock ( ) . set_lines ( vec ! [ ] ) ;
38+ let todo_state = self . todo_file . lock ( ) . state ( ) . clone ( ) ;
39+ if todo_state != TodoFileState :: Edit {
40+ self . todo_file . lock ( ) . set_lines ( vec ! [ ] ) ;
41+ }
3942 results. exit_status ( ExitStatus :: Good ) ;
4043 } ,
4144 Confirmed :: No => {
@@ -133,4 +136,24 @@ mod tests {
133136 } ,
134137 ) ;
135138 }
139+
140+ #[ test]
141+ fn handle_event_yes_in_edit ( ) {
142+ module_test (
143+ & [ "pick aaa comment" ] ,
144+ & [ Event :: from ( MetaEvent :: Yes ) ] ,
145+ |mut test_context| {
146+ let mut todo_file = test_context. take_todo_file ( ) ;
147+ todo_file. set_state ( TodoFileState :: Edit ) ;
148+
149+ let mut module = create_confirm_abort ( todo_file) ;
150+ assert_results ! (
151+ test_context. handle_event( & mut module) ,
152+ Artifact :: Event ( Event :: from( MetaEvent :: Yes ) ) ,
153+ Artifact :: ExitStatus ( ExitStatus :: Good )
154+ ) ;
155+ assert ! ( !module. todo_file. lock( ) . is_empty( ) ) ;
156+ } ,
157+ ) ;
158+ }
136159}
Original file line number Diff line number Diff line change @@ -205,6 +205,12 @@ impl TodoFile {
205205 self . history . reset ( ) ;
206206 }
207207
208+ /// Set the rebase todo file state.
209+ #[ inline]
210+ pub fn set_state ( & mut self , state : State ) {
211+ self . state = state;
212+ }
213+
208214 /// Load the rebase file from disk.
209215 ///
210216 /// # Errors
@@ -235,7 +241,7 @@ impl TodoFile {
235241 } )
236242 . collect ( ) ;
237243 self . set_lines ( lines?) ;
238- self . state = detect_state ( & self . filepath ) ?;
244+ self . set_state ( detect_state ( & self . filepath ) ?) ;
239245 Ok ( ( ) )
240246 }
241247
You can’t perform that action at this time.
0 commit comments