When history-limit is changed, apply to existing panes, not just new

ones. GitHub issue 4705.
This commit is contained in:
nicm
2026-01-22 08:55:01 +00:00
parent ecbf8d76d0
commit 195a9cfd88
7 changed files with 45 additions and 8 deletions

View File

@@ -82,7 +82,7 @@ grid_view_clear_history(struct grid *gd, u_int bg)
/* Scroll the lines into the history. */
for (yy = 0; yy < last; yy++) {
grid_collect_history(gd);
grid_collect_history(gd, 0);
grid_scroll_history(gd, bg);
}
if (last < gd->sy)
@@ -107,7 +107,7 @@ grid_view_scroll_region_up(struct grid *gd, u_int rupper, u_int rlower,
u_int bg)
{
if (gd->flags & GRID_HISTORY) {
grid_collect_history(gd);
grid_collect_history(gd, 0);
if (rupper == 0 && rlower == gd->sy - 1)
grid_scroll_history(gd, bg);
else {

5
grid.c
View File

@@ -375,13 +375,16 @@ grid_trim_history(struct grid *gd, u_int ny)
* and shift up.
*/
void
grid_collect_history(struct grid *gd)
grid_collect_history(struct grid *gd, int all)
{
u_int ny;
if (gd->hsize == 0 || gd->hsize < gd->hlimit)
return;
if (all)
ny = gd->hsize - gd->hlimit;
else
ny = gd->hlimit / 10;
if (ny < 1)
ny = 1;

View File

@@ -1252,6 +1252,10 @@ options_push_changes(const char *name)
utf8_update_width_cache();
if (strcmp(name, "input-buffer-size") == 0)
input_set_buffer_size(options_get_number(global_options, name));
if (strcmp(name, "history-limit") == 0) {
RB_FOREACH(s, sessions, &sessions)
session_update_history(s);
}
RB_FOREACH(s, sessions, &sessions)
status_update_cache(s);

View File

@@ -768,3 +768,29 @@ session_theme_changed(struct session *s)
}
}
}
/* Update history for all panes. */
void
session_update_history(struct session *s)
{
struct winlink *wl;
struct window_pane *wp;
struct grid *gd;
u_int limit, osize;
limit = options_get_number(s->options, "history-limit");
RB_FOREACH(wl, winlinks, &s->windows) {
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
gd = wp->base.grid;
osize = gd->hsize;
gd->hlimit = limit;
grid_collect_history(gd, 1);
if (gd->hsize != osize) {
log_debug("%s: %%%u %u -> %u", __func__, wp->id,
osize, gd->hsize);
}
}
}
}

4
tmux.1
View File

@@ -4583,9 +4583,7 @@ If set to 0, messages and indicators are displayed until a key is pressed.
.Ar time
is in milliseconds.
.It Ic history-limit Ar lines
Set the maximum number of lines held in window history.
This setting applies only to new windows - existing window histories are not
resized and retain the limit at the point they were created.
Set the maximum number of lines held in pane history.
.It Ic initial-repeat-time Ar time
Set the time in milliseconds for the initial repeat when a key is bound with the
.Fl r

3
tmux.h
View File

@@ -3002,7 +3002,7 @@ int grid_cells_look_equal(const struct grid_cell *,
struct grid *grid_create(u_int, u_int, u_int);
void grid_destroy(struct grid *);
int grid_compare(struct grid *, struct grid *);
void grid_collect_history(struct grid *);
void grid_collect_history(struct grid *, int);
void grid_remove_history(struct grid *, u_int );
void grid_scroll_history(struct grid *, u_int);
void grid_scroll_history_region(struct grid *, u_int, u_int, u_int);
@@ -3485,6 +3485,7 @@ u_int session_group_count(struct session_group *);
u_int session_group_attached_count(struct session_group *);
void session_renumber_windows(struct session *);
void session_theme_changed(struct session *);
void session_update_history(struct session *);
/* utf8.c */
enum utf8_state utf8_towc (const struct utf8_data *, wchar_t *);

View File

@@ -2708,6 +2708,11 @@ window_copy_cmd_refresh_from_pane(struct window_copy_cmd_state *cs)
data->backing = window_copy_clone_screen(&wp->base, &data->screen, NULL,
NULL, wme->swp != wme->wp);
if (data->oy > screen_hsize(data->backing)) {
data->cy = 0;
data->oy = screen_hsize(data->backing);
}
window_copy_size_changed(wme);
return (WINDOW_COPY_CMD_REDRAW);
}