@@ -6,10 +6,12 @@ use crate::{core_editor::get_default_clipboard, EditCommand};
66
77// Determines how we update the cut buffer when we next cut
88enum LastCutCommand {
9- // We are currently
10- ThisCommand ,
11- LastCommand ,
12- BeforeLastCommand ,
9+ // We are currently running a command that includes a cut command.
10+ This ,
11+ // We have just run a command that includes a cut command.
12+ Last ,
13+ // We have not recently run a cut command. Replace the cut buffer if another cut happens.
14+ BeforeLast ,
1315}
1416
1517// Which direction are we cutting in?
@@ -36,7 +38,7 @@ impl Default for Editor {
3638 Editor {
3739 line_buffer : LineBuffer :: new ( ) ,
3840 cut_buffer : Box :: new ( get_default_clipboard ( ) ) ,
39- last_cut_command : LastCutCommand :: BeforeLastCommand ,
41+ last_cut_command : LastCutCommand :: BeforeLast ,
4042 edit_stack : EditStack :: new ( ) ,
4143 last_undo_behavior : UndoBehavior :: CreateUndoPoint ,
4244 }
@@ -117,10 +119,8 @@ impl Editor {
117119 }
118120
119121 self . last_cut_command = match self . last_cut_command {
120- LastCutCommand :: ThisCommand => LastCutCommand :: LastCommand ,
121- LastCutCommand :: LastCommand | LastCutCommand :: BeforeLastCommand => {
122- LastCutCommand :: BeforeLastCommand
123- }
122+ LastCutCommand :: This => LastCutCommand :: Last ,
123+ LastCutCommand :: Last | LastCutCommand :: BeforeLast => LastCutCommand :: BeforeLast ,
124124 } ;
125125
126126 let new_undo_behavior = match ( command, command. edit_type ( ) ) {
@@ -249,7 +249,7 @@ impl Editor {
249249 // Otherwise, replace what's in the cut buffer.
250250 let buf;
251251 let cut_slice = match ( & self . last_cut_command , direction) {
252- ( LastCutCommand :: BeforeLastCommand , _) => cut_slice,
252+ ( LastCutCommand :: BeforeLast , _) => cut_slice,
253253 ( _, CutDirection :: Left ) => {
254254 let existing = self . cut_buffer . get ( ) . 0 ;
255255 buf = format ! ( "{cut_slice}{existing}" ) ;
@@ -272,7 +272,7 @@ impl Editor {
272272 self . line_buffer . set_insertion_point ( start) ;
273273 self . line_buffer . clear_range ( cut_range) ;
274274 }
275- self . last_cut_command = LastCutCommand :: ThisCommand ;
275+ self . last_cut_command = LastCutCommand :: This ;
276276 }
277277
278278 fn cut_current_line ( & mut self ) {
0 commit comments