Skip to content

Commit a656bb0

Browse files
lababidizerosnacks
andauthored
fix: adjust numerical cells in gas report to be right aligned (#12883)
* Adjust Cells to be Right Aligned in Gas Report * fix test and fmt --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
1 parent 3a7ed77 commit a656bb0

2 files changed

Lines changed: 94 additions & 84 deletions

File tree

crates/forge/src/gas_report.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use crate::{
55
traces::{CallTraceArena, CallTraceDecoder, CallTraceNode, DecodedCallData},
66
};
77
use alloy_primitives::map::HashSet;
8-
use comfy_table::{Cell, Color, Table, modifiers::UTF8_ROUND_CORNERS, presets::ASCII_MARKDOWN};
8+
use comfy_table::{
9+
Cell, CellAlignment, Color, Table, modifiers::UTF8_ROUND_CORNERS, presets::ASCII_MARKDOWN,
10+
};
911
use foundry_common::{TestFunctionExt, calc, shell};
1012
use foundry_evm::traces::CallKind;
1113

@@ -213,8 +215,8 @@ impl GasReport {
213215
Cell::new("Deployment Size").fg(Color::Cyan),
214216
]);
215217
table.add_row(vec![
216-
Cell::new(contract.gas.to_string()),
217-
Cell::new(contract.size.to_string()),
218+
Cell::new(contract.gas.to_string()).set_alignment(CellAlignment::Right),
219+
Cell::new(contract.size.to_string()).set_alignment(CellAlignment::Right),
218220
]);
219221

220222
// Add a blank row to separate deployment info from function info.
@@ -237,11 +239,19 @@ impl GasReport {
237239

238240
table.add_row(vec![
239241
Cell::new(display_name),
240-
Cell::new(gas_info.min.to_string()).fg(Color::Green),
241-
Cell::new(gas_info.mean.to_string()).fg(Color::Yellow),
242-
Cell::new(gas_info.median.to_string()).fg(Color::Yellow),
243-
Cell::new(gas_info.max.to_string()).fg(Color::Red),
244-
Cell::new(gas_info.calls.to_string()),
242+
Cell::new(gas_info.min.to_string())
243+
.fg(Color::Green)
244+
.set_alignment(CellAlignment::Right),
245+
Cell::new(gas_info.mean.to_string())
246+
.fg(Color::Yellow)
247+
.set_alignment(CellAlignment::Right),
248+
Cell::new(gas_info.median.to_string())
249+
.fg(Color::Yellow)
250+
.set_alignment(CellAlignment::Right),
251+
Cell::new(gas_info.max.to_string())
252+
.fg(Color::Red)
253+
.set_alignment(CellAlignment::Right),
254+
Cell::new(gas_info.calls.to_string()).set_alignment(CellAlignment::Right),
245255
]);
246256
})
247257
});

0 commit comments

Comments
 (0)