Mercurial > vim
comparison src/undo.c @ 18463:18d7337b6837 v8.1.2225
patch 8.1.2225: the "last used" info of a buffer is under used
Commit: https://github.com/vim/vim/commit/52410575be50d5c40bbe6380159df48cfc382ceb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 27 05:12:45 2019 +0100
patch 8.1.2225: the "last used" info of a buffer is under used
Problem: The "last used" info of a buffer is under used.
Solution: Add "lastused" to getbufinfo(). List buffers sorted by last-used
field. (Andi Massimino, closes #4722)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Oct 2019 05:15:06 +0100 |
parents | 59bc3cd42cf5 |
children | 9e6d5a4abb1c |
comparison
equal
deleted
inserted
replaced
18462:395349479800 | 18463:18d7337b6837 |
---|---|
104 static u_entry_T *u_get_headentry(void); | 104 static u_entry_T *u_get_headentry(void); |
105 static void u_getbot(void); | 105 static void u_getbot(void); |
106 static void u_doit(int count); | 106 static void u_doit(int count); |
107 static void u_undoredo(int undo); | 107 static void u_undoredo(int undo); |
108 static void u_undo_end(int did_undo, int absolute); | 108 static void u_undo_end(int did_undo, int absolute); |
109 static void u_add_time(char_u *buf, size_t buflen, time_t tt); | |
110 static void u_freeheader(buf_T *buf, u_header_T *uhp, u_header_T **uhpp); | 109 static void u_freeheader(buf_T *buf, u_header_T *uhp, u_header_T **uhpp); |
111 static void u_freebranch(buf_T *buf, u_header_T *uhp, u_header_T **uhpp); | 110 static void u_freebranch(buf_T *buf, u_header_T *uhp, u_header_T **uhpp); |
112 static void u_freeentries(buf_T *buf, u_header_T *uhp, u_header_T **uhpp); | 111 static void u_freeentries(buf_T *buf, u_header_T *uhp, u_header_T **uhpp); |
113 static void u_freeentry(u_entry_T *, long); | 112 static void u_freeentry(u_entry_T *, long); |
114 #ifdef FEAT_PERSISTENT_UNDO | 113 #ifdef FEAT_PERSISTENT_UNDO |
2971 uhp = curbuf->b_u_newhead; | 2970 uhp = curbuf->b_u_newhead; |
2972 | 2971 |
2973 if (uhp == NULL) | 2972 if (uhp == NULL) |
2974 *msgbuf = NUL; | 2973 *msgbuf = NUL; |
2975 else | 2974 else |
2976 u_add_time(msgbuf, sizeof(msgbuf), uhp->uh_time); | 2975 add_time(msgbuf, sizeof(msgbuf), uhp->uh_time); |
2977 | 2976 |
2978 #ifdef FEAT_CONCEAL | 2977 #ifdef FEAT_CONCEAL |
2979 { | 2978 { |
2980 win_T *wp; | 2979 win_T *wp; |
2981 | 2980 |
3048 { | 3047 { |
3049 if (ga_grow(&ga, 1) == FAIL) | 3048 if (ga_grow(&ga, 1) == FAIL) |
3050 break; | 3049 break; |
3051 vim_snprintf((char *)IObuff, IOSIZE, "%6ld %7d ", | 3050 vim_snprintf((char *)IObuff, IOSIZE, "%6ld %7d ", |
3052 uhp->uh_seq, changes); | 3051 uhp->uh_seq, changes); |
3053 u_add_time(IObuff + STRLEN(IObuff), IOSIZE - STRLEN(IObuff), | 3052 add_time(IObuff + STRLEN(IObuff), IOSIZE - STRLEN(IObuff), |
3054 uhp->uh_time); | 3053 uhp->uh_time); |
3055 if (uhp->uh_save_nr > 0) | 3054 if (uhp->uh_save_nr > 0) |
3056 { | 3055 { |
3057 while (STRLEN(IObuff) < 33) | 3056 while (STRLEN(IObuff) < 33) |
3058 STRCAT(IObuff, " "); | 3057 STRCAT(IObuff, " "); |
3119 msg_puts(((char **)ga.ga_data)[i]); | 3118 msg_puts(((char **)ga.ga_data)[i]); |
3120 } | 3119 } |
3121 msg_end(); | 3120 msg_end(); |
3122 | 3121 |
3123 ga_clear_strings(&ga); | 3122 ga_clear_strings(&ga); |
3124 } | |
3125 } | |
3126 | |
3127 /* | |
3128 * Put the timestamp of an undo header in "buf[buflen]" in a nice format. | |
3129 */ | |
3130 static void | |
3131 u_add_time(char_u *buf, size_t buflen, time_t tt) | |
3132 { | |
3133 #ifdef HAVE_STRFTIME | |
3134 struct tm tmval; | |
3135 struct tm *curtime; | |
3136 | |
3137 if (vim_time() - tt >= 100) | |
3138 { | |
3139 curtime = vim_localtime(&tt, &tmval); | |
3140 if (vim_time() - tt < (60L * 60L * 12L)) | |
3141 /* within 12 hours */ | |
3142 (void)strftime((char *)buf, buflen, "%H:%M:%S", curtime); | |
3143 else | |
3144 /* longer ago */ | |
3145 (void)strftime((char *)buf, buflen, "%Y/%m/%d %H:%M:%S", curtime); | |
3146 } | |
3147 else | |
3148 #endif | |
3149 { | |
3150 long seconds = (long)(vim_time() - tt); | |
3151 | |
3152 vim_snprintf((char *)buf, buflen, | |
3153 NGETTEXT("%ld second ago", "%ld seconds ago", seconds), | |
3154 seconds); | |
3155 } | 3123 } |
3156 } | 3124 } |
3157 | 3125 |
3158 /* | 3126 /* |
3159 * ":undojoin": continue adding to the last entry list | 3127 * ":undojoin": continue adding to the last entry list |