that is: treat the deletion of words like pressing Backspace/Delete.
* src/search.c (get_history_completion, find_history): Cycle through
the items from newest to oldest. This fixes Savannah bug #47205.
+ * src/files.c (do_writeout): When the name of the file was changed,
+ always ask whether this is okay. This fixes Savannah bug #46894.
2016-03-19 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (search_init): Always remember the last typed string,
#ifndef DISABLE_EXTRA
static bool did_credits = FALSE;
#endif
+ bool maychange = FALSE;
+ /* Whether it's okay to save the file under a different name. */
bool result = FALSE;
if (exiting && openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
if (ISSET(RESTRICTED))
continue;
- if (name_exists) {
- i = do_yesno_prompt(FALSE,
- _("File exists; OVERWRITE? "));
- if (i == 0 || i == -1)
- continue;
- } else
+ if (!maychange) {
#ifndef NANO_TINY
- if (exiting || !openfile->mark_set)
-#endif
- {
- i = do_yesno_prompt(FALSE,
- _("Save file under DIFFERENT NAME? "));
- if (i == 0 || i == -1)
+ if (exiting || !openfile->mark_set)
+#endif
+ {
+ i = do_yesno_prompt(FALSE,
+ _("Save file under DIFFERENT NAME? "));
+ if (i < 1)
+ continue;
+ maychange = TRUE;
+ }
+ }
+
+ if (name_exists) {
+ char *question = _("File \"%s\" exists; OVERWRITE? ");
+ char *message = charalloc(strlen(question) +
+ strlen(answer) + 1);
+ sprintf(message, question, answer);
+
+ i = do_yesno_prompt(FALSE, message);
+ free(message);
+
+ if (i < 1)
continue;
}
}