diff options
author | Sabu Siyad <hello@ssiyad.com> | 2022-08-03 02:13:37 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 20:43:37 +0000 |
commit | 76c5d01ee2b2178e71df578a109108655a97c24a (patch) | |
tree | 186412c5a5f1f8bb24c286b8b4c202c1ce05a4eb | |
parent | 1df32309fe69d4e8113813a3e9049a7039650f44 (diff) | |
download | alacritty-76c5d01ee2b2178e71df578a109108655a97c24a.tar.gz alacritty-76c5d01ee2b2178e71df578a109108655a97c24a.zip |
Warn if only columns XOR lines is set
Co-authored-by: Christian Duerr <contact@christianduerr.com>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty.yml | 7 | ||||
-rw-r--r-- | alacritty/src/config/window.rs | 30 |
3 files changed, 30 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 08c2db9d..3cd92c33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Blinking cursor will timeout after `5` seconds by default - Deprecated `colors.search.bar`, use `colors.footer_bar` instead - On macOS, Alacritty now reads `AppleFontSmoothing` from user defaults to control font smoothing +- Warn when either `columns` or `lines` is non-zero, but not both ### Fixed diff --git a/alacritty.yml b/alacritty.yml index 4301d8e1..0f7bb884 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -26,9 +26,10 @@ #window: # Window dimensions (changes require restart) # - # Number of lines/columns (not pixels) in the terminal. The number of columns - # must be at least `2`, while using a value of `0` for columns and lines will - # fall back to the window manager's recommended size. + # Number of lines/columns (not pixels) in the terminal. Both lines and columns + # must be non-zero for this to take effect. The number of columns must be at + # least `2`, while using a value of `0` for columns and lines will fall back + # to the window manager's recommended size #dimensions: # columns: 0 # lines: 0 diff --git a/alacritty/src/config/window.rs b/alacritty/src/config/window.rs index 813c0f3a..08f38b57 100644 --- a/alacritty/src/config/window.rs +++ b/alacritty/src/config/window.rs @@ -2,7 +2,7 @@ use std::fmt::{self, Formatter}; use std::os::raw::c_ulong; use glutin::window::Fullscreen; -use log::error; +use log::{error, warn}; use serde::de::{self, MapAccess, Visitor}; use serde::{Deserialize, Deserializer, Serialize}; @@ -74,11 +74,31 @@ impl Default for WindowConfig { impl WindowConfig { #[inline] pub fn dimensions(&self) -> Option<Dimensions> { - if self.dimensions.columns.0 != 0 - && self.dimensions.lines != 0 - && self.startup_mode != StartupMode::Maximized - { + let (lines, columns) = (self.dimensions.lines, self.dimensions.columns.0); + let (lines_is_non_zero, columns_is_non_zero) = (lines != 0, columns != 0); + + if lines_is_non_zero && columns_is_non_zero { + // Return dimensions if both `lines` and `columns` are non-zero. Some(self.dimensions) + } else if lines_is_non_zero || columns_is_non_zero { + // Warn if either `columns` or `lines` is non-zero. + + let (zero_key, non_zero_key, non_zero_value) = if lines_is_non_zero { + ("columns", "lines", lines) + } else { + ("lines", "columns", columns) + }; + + warn!( + target: LOG_TARGET_CONFIG, + "Both `lines` and `columns` must be non-zero for `window.dimensions` to take \ + effect. Configured value of `{}` is 0 while that of `{}` is {}", + zero_key, + non_zero_key, + non_zero_value, + ); + + None } else { None } |