diff --git a/src/browser.c b/src/browser.c index 31972be..ab5bfbf 100644 --- a/src/browser.c +++ b/src/browser.c @@ -41,8 +41,6 @@ static int longest = 0; /* The number of columns in the longest filename in the list. */ static size_t selected = 0; /* The currently selected filename in the list; zero-based. */ -static char *path_save = NULL; - /* A copy of the current path. */ /* Our main file browser function. path is the tilde-expanded path we * start browsing from. */ @@ -75,7 +73,7 @@ char *do_browser(char *path, DIR *dir) path = mallocstrassn(path, get_full_path(path)); /* Save the current path in order to be used later. */ - path_save = path; + where_we_are = mallocstrcpy(where_we_are, path); assert(path != NULL && path[strlen(path) - 1] == '/'); @@ -117,7 +115,7 @@ char *do_browser(char *path, DIR *dir) #ifndef NANO_TINY if (kbinput == KEY_WINCH) { /* Rebuild the file list and sort it. */ - browser_init(path_save, opendir(path_save)); + browser_init(where_we_are, opendir(where_we_are)); qsort(filelist, filelist_len, sizeof(char *), diralphasort); /* Make sure the selected file is within range. */ @@ -544,7 +542,7 @@ void browser_refresh(void) char *info; /* The additional information that we'll display about a file. */ - titlebar(path_save); + titlebar(where_we_are); blank_edit(); wmove(edit, 0, 0); diff --git a/src/files.c b/src/files.c index 4257651..78aa374 100644 --- a/src/files.c +++ b/src/files.c @@ -1120,6 +1120,7 @@ void do_insertfile( _("File to insert [from %s] "); } + where_we_are = mallocstrcpy(where_we_are, "./"); i = do_prompt(TRUE, #ifndef DISABLE_TABCOMP TRUE, @@ -2256,6 +2257,7 @@ int do_writeout(bool exiting) #endif openfile->filename); + while (TRUE) { const char *msg; #ifndef NANO_TINY @@ -2282,6 +2284,7 @@ int do_writeout(bool exiting) /* If we're using restricted mode, and the filename isn't blank, * disable tab completion. */ + where_we_are = mallocstrcpy(where_we_are, "./"); i = do_prompt(!ISSET(RESTRICTED) || openfile->filename[0] == '\0', #ifndef DISABLE_TABCOMP @@ -2686,7 +2689,7 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t free(wasdirname); } else { filename = dirname; - dirname = mallocstrcpy(NULL, "./"); + dirname = mallocstrcpy(NULL, where_we_are); } assert(dirname[strlen(dirname) - 1] == '/'); diff --git a/src/global.c b/src/global.c index 37de038..6ba6eeb 100644 --- a/src/global.c +++ b/src/global.c @@ -39,6 +39,8 @@ bool func_key; /* Whether the current keystroke is an extended keypad value. */ bool focusing = FALSE; /* Whether an update of the edit window should center the cursor. */ +char *where_we_are = NULL; + /* Stores current path in browser for cwd_tab_completion(). */ #ifndef NANO_TINY int controlleft = CONTROL_LEFT; diff --git a/src/proto.h b/src/proto.h index 5faa6e4..2a957ba 100644 --- a/src/proto.h +++ b/src/proto.h @@ -33,6 +33,7 @@ extern volatile sig_atomic_t sigwinch_counter; extern bool meta_key; extern bool func_key; extern bool focusing; +extern char *where_we_are; #ifndef NANO_TINY extern int controlleft;