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 c4ddf1c..b1faa75 100644 --- a/src/files.c +++ b/src/files.c @@ -1120,6 +1120,8 @@ void do_insertfile( _("File to insert [from %s] "); } + where_we_are = mallocstrcpy(where_we_are, "./"); + i = do_prompt(TRUE, #ifndef DISABLE_TABCOMP TRUE, @@ -2280,6 +2282,8 @@ int do_writeout(bool exiting) (append == APPEND) ? _("File Name to Append to") : _("File Name to Write"); + where_we_are = mallocstrcpy(where_we_are, "./"); + /* If we're using restricted mode, and the filename isn't blank, * disable tab completion. */ i = do_prompt(!ISSET(RESTRICTED) || @@ -2687,7 +2691,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..523579d 100644 --- a/src/global.c +++ b/src/global.c @@ -57,6 +57,9 @@ ssize_t wrap_at = -CHARS_FROM_EOL; char *last_search = NULL; /* The last string we searched for. */ +char *where_we_are = NULL; + /* The present directory when trying to do tab completion. */ + unsigned flags[4] = {0, 0, 0, 0}; /* Our flag containing the states of all global options. */ WINDOW *topwin; @@ -1647,6 +1650,7 @@ void thanks_for_all_the_fish(void) #endif free(answer); free(last_search); + free(where_we_are); #ifndef DISABLE_SPELLER free(alt_speller); #endif diff --git a/src/proto.h b/src/proto.h index 5faa6e4..bce6736 100644 --- a/src/proto.h +++ b/src/proto.h @@ -46,6 +46,8 @@ extern ssize_t wrap_at; extern char *last_search; +extern char *where_we_are; + extern unsigned flags[4]; extern WINDOW *topwin; extern WINDOW *edit;