diff --git a/ChangeLog b/ChangeLog index 48c4e00c381353c8614fd48ae6b5179b212d94a0..2c81aeb2ac4a859f72d695bc0d8dce6588cbef66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,9 +38,10 @@ CVS code - file help.c; changes to help_init(), help_line_len(), and do_help() (all moved to help.c). (DLR) - Tweak a few functions to remove the assumption that the file - always ends in a magicline. Changes to do_cut_till_end(), - open_buffer(), read_file(), write_file(), do_last_line(), - do_alt_speller(), and do_wordlinechar_count(). (DLR) + always ends in a magicline. Changes to cut_line(), + do_cut_till_end(), open_buffer(), read_file(), write_file(), + do_last_line(), do_alt_speller(), and do_wordlinechar_count(). + (DLR) - Tweak a few functions to rely on fileage and filebot instead of NULL for their checks to detect the top or bottom of the file. Changes to cut_line(), cut_to_eol(), do_page_up(), diff --git a/src/cut.c b/src/cut.c index 79bbf8bbc39ddaf11680691971ead635c661c654..5581a243d61b1b2151401168cc49bccc2772f18c 100644 --- a/src/cut.c +++ b/src/cut.c @@ -40,14 +40,24 @@ void cutbuffer_reset(void) /* If we're not on the last line of the file, move all the text of the * current line, plus the newline at the end, to the cutbuffer, and set - * the current place we want to where the line used to start. */ + * the current place we want to where the line used to start. If we + * are, and the last line of the file isn't blank, move all of the text + * of the current line to the cutbuffer, and set the current place we + * want to where the now-blank line starts. */ void cut_line(void) { - if (openfile->current != openfile->filebot) { + size_t data_len = strlen(openfile->current->data); + + assert(openfile->current_x <= data_len); + + if (openfile->current != openfile->filebot) move_to_filestruct(&cutbuffer, &cutbottom, openfile->current, 0, openfile->current->next, 0); - openfile->placewewant = xplustabs(); - } + else if (data_len > 0) + move_to_filestruct(&cutbuffer, &cutbottom, openfile->current, 0, + openfile->current, data_len); + + openfile->placewewant = xplustabs(); } #ifndef NANO_SMALL diff --git a/src/text.c b/src/text.c index 4d6d855bee9a05e1157ec68f16911a4dd8f75e36..c135c5d27a688851d47c188987a248d5dd05b1f7 100644 --- a/src/text.c +++ b/src/text.c @@ -96,6 +96,8 @@ void do_delete(void) openfile->mark_begin_x -= char_buf_len; #endif openfile->totsize--; + + set_modified(); } else if (openfile->current != openfile->filebot) { filestruct *foo = openfile->current->next; @@ -130,14 +132,17 @@ void do_delete(void) /* If the NO_NEWLINES flag isn't set, and text has been added to * the magicline as a result of deleting at the end of the line - * before filebot, add a new magicline. */ + * before filebot, add a new magicline. This effectively leaves + * the text unchanged, so don't mark the file as modified after + * doing this. */ if (!ISSET(NO_NEWLINES) && openfile->current == openfile->filebot && openfile->current->data[0] != '\0') new_magicline(); + else + set_modified(); } else return; - set_modified(); #ifdef ENABLE_COLOR /* If color syntaxes are available and turned on, we need to call