commit 982e226c3fcb7d6fe49e3e4385b69278eed7fbe2
parent 42ca89039aa72988b7e33a5d225b2d1977641944
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 8 May 2020 10:40:03 +0200
tweaks: elide three parameters, as they are the same for both calls
Diffstat:
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/history.c b/src/history.c
@@ -506,14 +506,14 @@ void reload_positions_if_needed(void)
}
}
-/* Update the recorded last file positions, given a filename, a line
- * and a column. If no entry is found, add a new one at the end. */
-void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
+/* Update the recorded last file positions with the current position in the
+ * current buffer. If no existing entry is found, add a new one at the end. */
+void update_poshistory(void)
{
poshiststruct *posptr, *theone, *posprev = NULL;
- char *fullpath = get_full_path(filename);
+ char *fullpath = get_full_path(openfile->filename);
- if (fullpath == NULL || *filename == '\0') {
+ if (fullpath == NULL || openfile->filename[0] == '\0') {
free(fullpath);
return;
}
@@ -528,7 +528,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
}
/* Don't record files that have the default cursor position. */
- if (lineno == 1 && xpos == 1) {
+ if (openfile->current->lineno == 1 && openfile->current_x == 0) {
if (posptr != NULL) {
if (posprev == NULL)
position_history = posptr->next;
@@ -564,8 +564,8 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
}
/* Store the last cursor position. */
- theone->lineno = lineno;
- theone->xno = xpos;
+ theone->lineno = openfile->current->lineno;
+ theone->xno = xplustabs() + 1;
theone->next = NULL;
free(fullpath);
diff --git a/src/nano.c b/src/nano.c
@@ -257,7 +257,7 @@ void finish(void)
if (ISSET(HISTORYLOG))
save_history();
if (ISSET(POSITIONLOG) && openfile)
- update_poshistory(openfile->filename, openfile->current->lineno, xplustabs() + 1);
+ update_poshistory();
#endif
/* Get out. */
@@ -768,8 +768,7 @@ void close_and_go(void)
if (openfile != openfile->next) {
#ifdef ENABLE_HISTORIES
if (ISSET(POSITIONLOG))
- update_poshistory(openfile->filename,
- openfile->current->lineno, xplustabs() + 1);
+ update_poshistory();
#endif
switch_to_next_buffer();
openfile = openfile->prev;
diff --git a/src/proto.h b/src/proto.h
@@ -357,7 +357,7 @@ bool have_statedir(void);
void load_history(void);
void save_history(void);
void load_poshistory(void);
-void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
+void update_poshistory(void);
bool has_old_position(const char *file, ssize_t *line, ssize_t *column);
#endif