Skip to content

Commit 2e10f54

Browse files
committed
[pager] use source line counts
1 parent b2e2d6e commit 2e10f54

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/base/math_util.hh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,22 @@ count_digits(T n)
162162
return n == 0 ? 1 : 1 + std::floor(std::log10(std::abs(n)));
163163
}
164164

165+
namespace lnav::math {
166+
167+
template<typename T>
168+
T
169+
vmax(T a, T b)
170+
{
171+
return (a > b) ? a : b;
172+
}
173+
174+
template<typename T, typename... Args>
175+
T
176+
vmax(T a, T b, Args... args)
177+
{
178+
return vmax(vmax(a, b), args...);
179+
}
180+
181+
} // namespace lnav::math
182+
165183
#endif

src/lnav.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4172,10 +4172,12 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
41724172
{
41734173
log_info(" input fully consumed");
41744174
rebuild_indexes_repeatedly();
4175-
if (lnav_data.ld_active_files.fc_files.empty()
4176-
|| lnav_data.ld_active_files.fc_files[0]->size()
4177-
< term_size.ws_row - 3)
4178-
{
4175+
4176+
auto max_height = lnav::math::vmax(
4177+
lnav_data.ld_log_source.text_line_count(),
4178+
lnav_data.ld_text_source.text_line_count());
4179+
4180+
if (max_height < term_size.ws_row - 3) {
41794181
log_info(" input is smaller than screen, not paging");
41804182
lnav_data.ld_flags.set<lnav_flags::headless>();
41814183
verbosity = verbosity_t::standard;

0 commit comments

Comments
 (0)