Index: src/text.c =================================================================== --- src/text.c (revision 5238) +++ src/text.c (working copy) @@ -120,13 +120,13 @@ assert(openfile->current_x == strlen(openfile->current->data)); + if (!ISSET(NO_NEWLINES) && foo == openfile->filebot) + /* Don't delete the magic line. */ + return; + #ifndef NANO_TINY add_undo(action); #endif - /* If we're deleting at the end of a line, we need to call - * edit_refresh(). */ - if (openfile->current->data[openfile->current_x] == '\0') - edit_refresh_needed = TRUE; openfile->current->data = charealloc(openfile->current->data, strlen(openfile->current->data) + strlen(foo->data) + 1); @@ -141,17 +141,13 @@ if (openfile->filebot == foo) openfile->filebot = openfile->current; + /* We have joined two lines, so we need to call edit_refresh(). */ + edit_refresh_needed = TRUE; + unlink_node(foo); delete_node(foo); renumber(openfile->current); openfile->totsize--; - - /* 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. */ - if (!ISSET(NO_NEWLINES) && openfile->current == - openfile->filebot && openfile->current->data[0] != '\0') - new_magicline(); } else return;