[pretty] drop extra new lines

This commit is contained in:
Timothy Stack 2015-04-05 11:59:14 -07:00
parent da73110578
commit 7b8bc67cc9
4 changed files with 14 additions and 15 deletions

View File

@ -1217,7 +1217,7 @@ static void open_pretty_view(void)
bool first_line = true;
delete pretty_tc->get_sub_source();
for (vis_line_t vl = log_tc->get_top(); vl < log_tc->get_bottom(); ++vl) {
for (vis_line_t vl = log_tc->get_top(); vl <= log_tc->get_bottom(); ++vl) {
content_line_t cl = lss.at(vl);
logfile *lf = lss.find(cl);
logfile::iterator ll = lf->begin() + cl;
@ -1242,6 +1242,9 @@ static void open_pretty_view(void)
}
lnav_data.ld_last_pretty_print_top = log_tc->get_top();
}
else {
log_warning("no log data to pretty-print");
}
}
bool toggle_view(textview_curses *toggle_tc)

View File

@ -176,9 +176,10 @@ private:
if (this->pp_line_length > 0) {
this->pp_stream << std::endl;
this->pp_line_length = 0;
}
has_output = this->flush_values();
if (has_output) {
if (has_output && this->pp_line_length > 0) {
this->pp_stream << std::endl;
}
this->pp_line_length = 0;
@ -195,7 +196,9 @@ private:
if (start_on_depth &&
(el.e_token == DT_LSQUARE ||
el.e_token == DT_LCURLY)) {
this->pp_stream << std::endl;
if (this->pp_line_length > 0) {
this->pp_stream << std::endl;
}
this->pp_line_length = 0;
}
}

View File

@ -14,7 +14,5 @@ pair 51:61 ^--------^ <clo
--
<ns1:foo>
<elem attr1=xyz attr2="123"> </elem>
<closed />

View File

@ -360,28 +360,25 @@ run_test ${lnav_test} -n \
${test_dir}/logfile_vami.0
check_output "pretty-printer is not working" <<EOF
2015-03-12T23:16:52.071:INFO:com.root:Response :
<?xml version="1.0"?>
<response>
<locale>en-US</locale>
<requestid>ipInfo</requestid>
<value id="ipv4Gateway" actions="enabled">10.133.235.253</value>
<value id="ipv4Gateway" actions="enabled">10.133.235.253 (unknown)</value>
<value id="ipv6Gateway" actions="enabled"/>
<value id="ipv6Enabled" actions="enabled">true</value>
<value id="ipv4Enabled" actions="enabled">true</value>
<value id="name" actions="enabled">nic1</value>
<value id="v4config" actions="enabled">
<value id="defaultGateway" actions="enabled">0.0.0.0</value>
<value id="defaultGateway" actions="enabled">0.0.0.0 (unknown)</value>
<value id="updateable" actions="enabled">True</value>
<value id="prefix" actions="enabled">22</value>
<value id="mode" actions="enabled">dhcp</value>
<value id="address" actions="enabled">10.133.234.110</value>
<value id="address" actions="enabled">10.133.234.110 (unknown)</value>
<value id="interface" actions="enabled">nic1</value>
</value>
<value id="v6config" actions="enabled">
<value id="defaultGateway" actions="enabled">fe80::214:f609:19f7:6bf1</value>
<value id="defaultGateway" actions="enabled">fe80::214:f609:19f7:6bf1 (unknown)</value>
<value id="updateable" actions="enabled">True</value>
<value id="interface" actions="enabled">nic1</value>
<value id="dhcp" actions="enabled">False</value>
@ -390,7 +387,7 @@ check_output "pretty-printer is not working" <<EOF
<value id="origin" actions="enabled">other</value>
<value id="status" actions="enabled">preferred</value>
<value id="prefix" actions="enabled">64</value>
<value id="address" actions="enabled">fe80::250:56ff:feaa:5abf</value>
<value id="address" actions="enabled">fe80::250:56ff:feaa:5abf (unknown)</value>
</value>
</value>
<value id="interfaceInfo" actions="enabled">
@ -400,8 +397,6 @@ check_output "pretty-printer is not working" <<EOF
</value>
</response>
EOF