zapping: use the 'keep_cutbuffer' logic to keep undo items apart
The 'keep_cutbuffer' variable becomes FALSE whenever there is cursor movement or there was a marked region. Use this variable to simplify the condition for creating a new ZAP undo item. But then typing the 'zap' shortcut should not cause the variable to be set to FALSE. This fixes the first part of https://savannah.gnu.org/bugs/?56261. Bug existed since zapping was introduced, in version 3.2.master
parent
b50d5758ef
commit
edf6995be4
|
@ -380,8 +380,10 @@ void do_cut_text_void(void)
|
||||||
|
|
||||||
/* Only add a new undo item when the current item is not a CUT or when
|
/* 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. */
|
* the current cut is not contiguous with the previous cutting. */
|
||||||
if (openfile->last_action != CUT || !keep_cutbuffer)
|
if (openfile->last_action != CUT || !keep_cutbuffer) {
|
||||||
|
keep_cutbuffer = FALSE;
|
||||||
add_undo(CUT);
|
add_undo(CUT);
|
||||||
|
}
|
||||||
|
|
||||||
do_cut_text(FALSE, openfile->mark != NULL, FALSE, FALSE);
|
do_cut_text(FALSE, openfile->mark != NULL, FALSE, FALSE);
|
||||||
|
|
||||||
|
@ -450,9 +452,7 @@ void zap_text(void)
|
||||||
|
|
||||||
/* Add a new undo item only when the current item is not a ZAP or when
|
/* 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. */
|
* the current zap is not contiguous with the previous zapping. */
|
||||||
if (openfile->last_action != ZAP || openfile->mark != NULL ||
|
if (openfile->last_action != ZAP || !keep_cutbuffer)
|
||||||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
|
|
||||||
openfile->current_undo->xflags & (MARK_WAS_SET|WAS_MARKED_FORWARD))
|
|
||||||
add_undo(ZAP);
|
add_undo(ZAP);
|
||||||
|
|
||||||
/* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
|
/* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
|
||||||
|
|
|
@ -1723,7 +1723,7 @@ void do_input(void)
|
||||||
/* When not cutting or copying text, drop the cutbuffer the next time. */
|
/* When not cutting or copying text, drop the cutbuffer the next time. */
|
||||||
if (shortcut->func != do_cut_text_void) {
|
if (shortcut->func != do_cut_text_void) {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (shortcut->func != do_copy_text)
|
if (shortcut->func != do_copy_text && shortcut->func != zap_text)
|
||||||
#endif
|
#endif
|
||||||
keep_cutbuffer = FALSE;
|
keep_cutbuffer = FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue