commit e0c5c589ad3d1eccb4264e5e18e97babdf0cb437
parent dfe87540c625e62f4169b9605af3f4a22e52eb7c
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 3 May 2019 12:14:49 +0200
tweaks: remove a superfluous condition, in three places
When 'last_action' has a specific value, then necessarily there must
exist a corresponding current undo item.
(The condition is already absent in do_deletion(), for the BACK and DEL
undo items, and it works fine there.)
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/cut.c b/src/cut.c
@@ -380,7 +380,7 @@ void do_cut_text_void(void)
/* Only add a new undo item when the current item is not a CUT or when
* the current cut is not contiguous with the previous cutting. */
- if (openfile->last_action != CUT || openfile->current_undo == NULL ||
+ if (openfile->last_action != CUT ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
!keep_cutbuffer)
add_undo(CUT);
@@ -448,7 +448,7 @@ void zap_text(void)
/* Add a new undo item only when the current item is not a ZAP or when
* the current zap is not contiguous with the previous zapping. */
- if (openfile->last_action != ZAP || openfile->current_undo == NULL ||
+ if (openfile->last_action != ZAP ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
openfile->current_undo->xflags & (MARK_WAS_SET|WAS_MARKED_FORWARD))
add_undo(ZAP);
diff --git a/src/nano.c b/src/nano.c
@@ -1832,7 +1832,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#ifndef NANO_TINY
/* Only add a new undo item when the current item is not an ADD or when
* the current typing is not contiguous with the previous typing. */
- if (openfile->last_action != ADD || openfile->current_undo == NULL ||
+ if (openfile->last_action != ADD ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
openfile->current_undo->mark_begin_x != openfile->current_x)
add_undo(ADD);