From 13ac944e7fec959e60f19dccf92dc0121189df44 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 28 Dec 2021 08:50:43 -0700 Subject: [PATCH] cargo fmt refs: #1468 --- wezterm-gui/src/scripting/pane.rs | 37 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/wezterm-gui/src/scripting/pane.rs b/wezterm-gui/src/scripting/pane.rs index 2a721cfdb..c278826fe 100644 --- a/wezterm-gui/src/scripting/pane.rs +++ b/wezterm-gui/src/scripting/pane.rs @@ -81,25 +81,28 @@ impl UserData for PaneObject { Ok(text) }); - methods.add_method("get_logical_lines_as_text", |_, this, nlines: Option| { - let pane = this.pane()?; - let dims = pane.get_dimensions(); - let nlines = nlines.unwrap_or(dims.viewport_rows); - let bottom_row = dims.physical_top + dims.viewport_rows as isize; - let top_row = bottom_row.saturating_sub(nlines as isize); - let lines = pane.get_logical_lines(top_row..bottom_row); - let mut text = String::new(); - for line in lines { - for (_, cell) in line.logical.visible_cells() { - text.push_str(cell.str()); + methods.add_method( + "get_logical_lines_as_text", + |_, this, nlines: Option| { + let pane = this.pane()?; + let dims = pane.get_dimensions(); + let nlines = nlines.unwrap_or(dims.viewport_rows); + let bottom_row = dims.physical_top + dims.viewport_rows as isize; + let top_row = bottom_row.saturating_sub(nlines as isize); + let lines = pane.get_logical_lines(top_row..bottom_row); + let mut text = String::new(); + for line in lines { + for (_, cell) in line.logical.visible_cells() { + text.push_str(cell.str()); + } + let trimmed = text.trim_end().len(); + text.truncate(trimmed); + text.push('\n'); } let trimmed = text.trim_end().len(); text.truncate(trimmed); - text.push('\n'); - } - let trimmed = text.trim_end().len(); - text.truncate(trimmed); - Ok(text) - }); + Ok(text) + }, + ); } }