* src/text.c (do_undo, add_undo): Skip undoing a backspace *only* when
it really tried to delete the final, magic newline.
* src/nano.h, src/text.c: Rename three flags for clarity.
+ * src/files.c (replace_buffer): This function is only ever called with
+ a temporary file as parameter, so forget the case of an empty filename.
+ Also, don't bother putting the pointer at the top of the buffer, as the
+ first action after this function is to restore the cursor position.
2015-06-23 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (edit_draw): Verify that there exists multidata for the
}
#ifndef DISABLE_SPELLER
-/* If it's not "", filename is a file to open. We blow away the text of
- * the current buffer, and then open and read the file, if
- * applicable. Note that we skip the operating directory test when
- * doing this. */
+/* Blow away the text of the current buffer, and then open and read
+ * the specified file into its place. */
void replace_buffer(const char *filename)
{
FILE *f;
- int rc;
- /* rc == -2 means that we have a new file. -1 means that the
- * open() failed. 0 means that the open() succeeded. */
+ int descriptor;
- assert(filename != NULL);
+ assert(filename != NULL && filename[0] != '\0');
- /* If the filename isn't blank, open the file. Otherwise, treat it
- * as a new file. */
- rc = (filename[0] != '\0') ? open_file(filename, TRUE, FALSE, &f) : -2;
+ /* Open the file quietly. */
+ descriptor = open_file(filename, TRUE, FALSE, &f);
/* Reinitialize the text of the current buffer. */
free_filestruct(openfile->fileage);
initialize_buffer_text();
- /* If we have a non-new file, read it in. */
- if (rc > 0)
- read_file(f, rc, filename, FALSE, TRUE);
+ /* If opening the file succeeded, read it in. */
+ if (descriptor > 0)
+ read_file(f, descriptor, filename, FALSE, TRUE);
- /* Move back to the beginning of the first line of the buffer. */
- openfile->current = openfile->fileage;
- openfile->current_x = 0;
- openfile->placewewant = 0;
}
#endif /* !DISABLE_SPELLER */