mirror of
https://github.com/git-for-windows/git.git
synced 2026-04-27 09:29:33 -05:00
Merge pull request #3272 from dscho/fix-duplicated-lines-when-moving-in-pager
Fix duplicated lines when scrolling in the pager
This commit is contained in:
16
pager.c
16
pager.c
@@ -11,6 +11,10 @@
|
||||
static struct child_process pager_process = CHILD_PROCESS_INIT;
|
||||
static const char *pager_program;
|
||||
|
||||
/* Is the value coming back from term_columns() just a guess? */
|
||||
static int term_columns_guessed;
|
||||
|
||||
|
||||
static void close_pager_fds(void)
|
||||
{
|
||||
/* signal EOF to pager */
|
||||
@@ -114,7 +118,8 @@ void setup_pager(void)
|
||||
{
|
||||
char buf[64];
|
||||
xsnprintf(buf, sizeof(buf), "%d", term_columns());
|
||||
setenv("COLUMNS", buf, 0);
|
||||
if (!term_columns_guessed)
|
||||
setenv("COLUMNS", buf, 0);
|
||||
}
|
||||
|
||||
setenv("GIT_PAGER_IN_USE", "true", 1);
|
||||
@@ -158,15 +163,20 @@ int term_columns(void)
|
||||
return term_columns_at_startup;
|
||||
|
||||
term_columns_at_startup = 80;
|
||||
term_columns_guessed = 1;
|
||||
|
||||
col_string = getenv("COLUMNS");
|
||||
if (col_string && (n_cols = atoi(col_string)) > 0)
|
||||
if (col_string && (n_cols = atoi(col_string)) > 0) {
|
||||
term_columns_at_startup = n_cols;
|
||||
term_columns_guessed = 0;
|
||||
}
|
||||
#ifdef TIOCGWINSZ
|
||||
else {
|
||||
struct winsize ws;
|
||||
if (!ioctl(1, TIOCGWINSZ, &ws) && ws.ws_col)
|
||||
if (!ioctl(1, TIOCGWINSZ, &ws) && ws.ws_col) {
|
||||
term_columns_at_startup = ws.ws_col;
|
||||
term_columns_guessed = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user