the text of the current line (if any), minus the nonexistent newline,
when we're on the last line of the file, and make sure again that the
file isn't marked as modified if the magicline is deleted and we're
supposed to have one, as it's more consistent that way (a marked cut of
the magicline adds a newline to the cutbuffer, while deleting the
magicline adds nothing)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3114
35c25a1d-7b9e-4130-9fde-
d3aeb78583b8
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(),
/* 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
openfile->mark_begin_x -= char_buf_len;
#endif
openfile->totsize--;
+
+ set_modified();
} else if (openfile->current != openfile->filebot) {
filestruct *foo = openfile->current->next;
/* 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