Skip to content

Commit

Permalink
Adds config option for command palette rows (#4595)
Browse files Browse the repository at this point in the history
Co-authored-by: Wez Furlong <[email protected]>
  • Loading branch information
exastone and wez authored Dec 1, 2023
1 parent d7a2e25 commit 28ac1c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub struct Config {
#[dynamic(default = "default_command_palette_font_size")]
pub command_palette_font_size: f64,

pub command_palette_rows: Option<usize>,
#[dynamic(default = "default_command_palette_fg_color")]
pub command_palette_fg_color: RgbaColor,

Expand Down
12 changes: 12 additions & 0 deletions docs/config/lua/config/command_palette_rows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
tags:
- appearance
- command_palette
---
# `command_palette_rows = 14`

{{since('nightly')}}

Specifies the number of rows displayed by the command palette.
[ActivateCommandPalette](../keyassignment/ActivateCommandPalette.md).
If unset or `nil`, a default value based on the terminal display will be used.
5 changes: 4 additions & 1 deletion wezterm-gui/src/termwindow/palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,12 @@ impl Modal for CommandPalette {
.expect("to resolve char selection font");
let metrics = RenderMetrics::with_font_metrics(&font.metrics());

let max_rows_on_screen = ((term_window.dimensions.pixel_height * 8 / 10)
let mut max_rows_on_screen = ((term_window.dimensions.pixel_height * 8 / 10)
/ metrics.cell_size.height as usize)
- 2;
if let Some(size) = term_window.config.command_palette_rows {
max_rows_on_screen = max_rows_on_screen.min(size);
}
*self.max_rows_on_screen.borrow_mut() = max_rows_on_screen;

let rebuild_matches = results
Expand Down

0 comments on commit 28ac1c8

Please sign in to comment.