From 7e62d109baa47629e3a0b65d3d679b35d213370f Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 6 Jun 2005 19:25:29 +0000
Subject: [PATCH] in do_insertfile(), set i to 0 when we get a filename via the
 file browser, so that it's read in properly when we exit the file browser

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2604 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |  4 ++++
 src/files.c | 21 +++++++++++----------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 299a475f..8de5249e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -69,6 +69,10 @@ CVS code -
   get_next_filename()
 	- Use an unsigned long instead of an int for the number
 	  prepended to the filename. (DLR)
+  do_insertfile()
+	- Set i to 0 when we get a filename via the file browser, so
+	  that it's read in properly when we exit the file browser.
+	  (DLR)
   write_file()
 	- Since lineswritten is a size_t, print its value as an unsigned
 	  long instead of an unsigned int. (DLR)
diff --git a/src/files.c b/src/files.c
index 289264df..2a42664e 100644
--- a/src/files.c
+++ b/src/files.c
@@ -569,7 +569,8 @@ void do_insertfile(
 
 	    ans = mallocstrcpy(ans, answer);
 
-#if !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
+#ifndef NANO_SMALL
+#ifdef ENABLE_MULTIBUFFER
 	    if (i == TOGGLE_MULTIBUFFER_KEY) {
 		/* Don't allow toggling if we're in view mode. */
 		if (!ISSET(VIEW_MODE))
@@ -578,6 +579,12 @@ void do_insertfile(
 	    }
 #endif
 
+	    if (i == NANO_TOOTHERINSERT_KEY) {
+		execute = !execute;
+		continue;
+	    }
+#endif /* !NANO_SMALL */
+
 #ifndef DISABLE_BROWSER
 	    if (i == NANO_TOFILES_KEY) {
 		char *tmp = do_browse_from(answer);
@@ -588,19 +595,13 @@ void do_insertfile(
 		free(answer);
 		answer = tmp;
 
-		/* We have a file now.  Get out of the statusbar prompt
-		 * cleanly. */
+		/* We have a file now.  Indicate this and get out of the
+		 * statusbar prompt cleanly. */
+		i = 0;
 		statusq_abort();
 	    }
 #endif
 
-#ifndef NANO_SMALL
-	    if (i == NANO_TOOTHERINSERT_KEY) {
-		execute = !execute;
-		continue;
-	    }
-#endif
-
 	    /* If we don't have a file yet, go back to the statusbar
 	     * prompt. */
 	    if (i != 0
-- 
GitLab