copying: with --nonewlines, don't add a final newline to the cutbuffer
This fixes https://savannah.gnu.org/bugs/?58086.
Bug existed since commit f52b6cf1
from yesterday.
master
parent
96046f1e82
commit
4b814698bd
11
src/cut.c
11
src/cut.c
|
@ -564,6 +564,7 @@ void copy_marked_region(void)
|
||||||
void copy_text(void)
|
void copy_text(void)
|
||||||
{
|
{
|
||||||
bool at_eol = (openfile->current->data[openfile->current_x] == '\0');
|
bool at_eol = (openfile->current->data[openfile->current_x] == '\0');
|
||||||
|
bool on_last_line = (openfile->current->next == NULL);
|
||||||
linestruct *addition;
|
linestruct *addition;
|
||||||
|
|
||||||
if (openfile->mark || openfile->last_action != COPY || !keep_cutbuffer) {
|
if (openfile->mark || openfile->last_action != COPY || !keep_cutbuffer) {
|
||||||
|
@ -610,11 +611,19 @@ void copy_text(void)
|
||||||
} else {
|
} else {
|
||||||
addition->data = copy_of(openfile->current->data);
|
addition->data = copy_of(openfile->current->data);
|
||||||
|
|
||||||
if (cutbuffer == NULL) {
|
if (cutbuffer == NULL && on_last_line && ISSET(NO_NEWLINES)) {
|
||||||
|
cutbuffer = addition;
|
||||||
|
cutbottom = addition;
|
||||||
|
} else if (cutbuffer == NULL) {
|
||||||
cutbuffer = addition;
|
cutbuffer = addition;
|
||||||
cutbottom = make_new_node(cutbuffer);
|
cutbottom = make_new_node(cutbuffer);
|
||||||
cutbottom->data = copy_of("");
|
cutbottom->data = copy_of("");
|
||||||
cutbuffer->next = cutbottom;
|
cutbuffer->next = cutbottom;
|
||||||
|
} else if (on_last_line && ISSET(NO_NEWLINES)) {
|
||||||
|
addition->prev = cutbottom->prev;
|
||||||
|
addition->prev->next = addition;
|
||||||
|
delete_node(cutbottom);
|
||||||
|
cutbottom = addition;
|
||||||
} else {
|
} else {
|
||||||
addition->prev = cutbottom->prev;
|
addition->prev = cutbottom->prev;
|
||||||
addition->prev->next = addition;
|
addition->prev->next = addition;
|
||||||
|
|
Loading…
Reference in New Issue