fix breakage when NO_NEWLINES is FALSE and we copy text that would
require adding a new magicline then git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3440 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
c838a4cd45
commit
c208ef7f23
16
src/cut.c
16
src/cut.c
|
@ -115,6 +115,7 @@ void do_cut_text(
|
||||||
/* The current end of the cutbuffer, before we add text to
|
/* The current end of the cutbuffer, before we add text to
|
||||||
* it. */
|
* it. */
|
||||||
bool old_mark_set = openfile->mark_set;
|
bool old_mark_set = openfile->mark_set;
|
||||||
|
bool old_no_newlines = ISSET(NO_NEWLINES);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||||
|
@ -132,12 +133,18 @@ void do_cut_text(
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
if (copy_text) {
|
||||||
if (cutbuffer != NULL) {
|
if (cutbuffer != NULL) {
|
||||||
/* If the cutbuffer isn't empty, save where it currently ends.
|
/* If the cutbuffer isn't empty, save where it currently
|
||||||
* This is where the new text will be added. */
|
* ends. This is where the new text will be added. */
|
||||||
cb_save = cutbottom;
|
cb_save = cutbottom;
|
||||||
cb_save->data += strlen(cb_save->data);
|
cb_save->data += strlen(cb_save->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set NO_NEWLINES to TRUE, so that we don't disturb the last
|
||||||
|
* line of the file when moving text to the cutbuffer. */
|
||||||
|
SET(NO_NEWLINES);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set keep_cutbuffer to TRUE, so that the text we're going to move
|
/* Set keep_cutbuffer to TRUE, so that the text we're going to move
|
||||||
|
@ -169,6 +176,11 @@ void do_cut_text(
|
||||||
if (cutbuffer != NULL)
|
if (cutbuffer != NULL)
|
||||||
copy_from_filestruct((cb_save != NULL) ? cb_save :
|
copy_from_filestruct((cb_save != NULL) ? cb_save :
|
||||||
cutbuffer, cutbottom);
|
cutbuffer, cutbottom);
|
||||||
|
|
||||||
|
/* Set NO_NEWLINES back to what it was before, since we're done
|
||||||
|
* disturbing the text. */
|
||||||
|
if (!old_no_newlines)
|
||||||
|
UNSET(NO_NEWLINES);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
/* Leave the text in the cutbuffer, and mark the file as
|
/* Leave the text in the cutbuffer, and mark the file as
|
||||||
|
|
Loading…
Reference in New Issue