Commit e642197f authored by Chris Allegretta's avatar Chris Allegretta
Browse files

new_file() and close_open_file() fixes by DLR

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@735 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 21 additions and 6 deletions
+21 -6
...@@ -3,8 +3,12 @@ CVS code - ...@@ -3,8 +3,12 @@ CVS code -
main() main()
- Change the getop option to 'F' (David Lawrence Ramsey) - Change the getop option to 'F' (David Lawrence Ramsey)
- files.c: - files.c:
do_writeout() new_file()
- Check for open_files == NULL before using it (Ryan Krebs) - Do add_open_files if there aren't any open yet (David Lawrence
Ramsey).
close_open_file()
- Try to open the next file first, then the previous one
(David Lawrence Ramsey).
- global.c: - global.c:
shortcut_init() shortcut_init()
- Rewrote the whereis and replace lists to put CANCEL at the end - Rewrote the whereis and replace lists to put CANCEL at the end
......
...@@ -74,6 +74,17 @@ void new_file(void) ...@@ -74,6 +74,17 @@ void new_file(void)
editbot = fileage; editbot = fileage;
current = fileage; current = fileage;
totlines = 1; totlines = 1;
#ifdef ENABLE_MULTIBUFFER
/* if there aren't any entries in open_files, create the entry for
this new file, and, of course, don't bother checking for
duplicates; without this, if nano is started without a filename on
the command line, a new file with no name will be created, but it
will be given no open_files entry, leading to problems later on */
if (!open_files)
add_open_file(0, 0);
#endif
UNSET(VIEW_MODE); UNSET(VIEW_MODE);
} }
...@@ -730,7 +741,7 @@ int open_nextfile(int closing_file) ...@@ -730,7 +741,7 @@ int open_nextfile(int closing_file)
/* /*
* Delete an entry from the open_files filestruct. After deletion of an * Delete an entry from the open_files filestruct. After deletion of an
* entry, the previous or next entry is opened, whichever is found first. * entry, the next or previous entry is opened, whichever is found first.
* Return 0 on success or 1 on error. * Return 0 on success or 1 on error.
*/ */
int close_open_file(void) int close_open_file(void)
...@@ -741,8 +752,8 @@ int close_open_file(void) ...@@ -741,8 +752,8 @@ int close_open_file(void)
return 1; return 1;
tmp = open_files; tmp = open_files;
if (open_prevfile(1)) { if (open_nextfile(1)) {
if (open_nextfile(1)) if (open_prevfile(1))
return 1; return 1;
} }
...@@ -1168,7 +1179,7 @@ int do_writeout(char *path, int exiting, int append) ...@@ -1168,7 +1179,7 @@ int do_writeout(char *path, int exiting, int append)
update the filename and full path stored in the update the filename and full path stored in the
current entry, and then update the current entry, current entry, and then update the current entry,
checking for duplicate entries */ checking for duplicate entries */
if (open_files != NULL && strcmp(open_files->data, filename)) { if (strcmp(open_files->data, filename)) {
open_file_change_name(); open_file_change_name();
add_open_file(1, 1); add_open_file(1, 1);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment