Skip to content

Commit

Permalink
minimize description padding
Browse files Browse the repository at this point in the history
  • Loading branch information
maxomatic458 committed Jan 9, 2024
1 parent ddb6aae commit 594955c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/menu/ide_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ impl IdeMenu {
let max_width = self
.default_details
.max_description_width
.min(available_width)
.max(self.default_details.min_description_width);
.clamp(self.default_details.min_description_width, available_width);

let max_height = self
.default_details
.max_description_height
Expand All @@ -404,6 +404,12 @@ impl IdeMenu {
let mut description_lines =
split_string(&description, content_width, content_height, "...");

let content_width = description_lines
.iter()
.map(|s| s.len())
.max()
.unwrap_or_default();

let needs_padding = description_lines.len() > 1;

if let Some(border) = &self.default_details.border {
Expand Down Expand Up @@ -497,12 +503,14 @@ impl IdeMenu {
} else {

Check warning on line 503 in src/menu/ide_menu.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, bashisms)

Diff in /home/runner/work/reedline/reedline/src/menu/ide_menu.rs

Check warning on line 503 in src/menu/ide_menu.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, default)

Diff in /home/runner/work/reedline/reedline/src/menu/ide_menu.rs

Check warning on line 503 in src/menu/ide_menu.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, sqlite)

Diff in /home/runner/work/reedline/reedline/src/menu/ide_menu.rs

Check warning on line 503 in src/menu/ide_menu.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, basqlite)

Diff in /home/runner/work/reedline/reedline/src/menu/ide_menu.rs

Check warning on line 503 in src/menu/ide_menu.rs

View workflow job for this annotation

GitHub Actions / build-lint-test (ubuntu-latest, stable, external_printer)

Diff in /home/runner/work/reedline/reedline/src/menu/ide_menu.rs
0
};

let vertical_border = self
.default_details
.border
.as_ref()
.map(|border| border.vertical)
.unwrap_or_default();

let padding_right = self
.working_details
.completion_width
Expand Down

0 comments on commit 594955c

Please sign in to comment.