From 650b5a0cbaccc6de2b53240372c2be79739d5d12 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 6 Jan 2018 00:50:12 +0000 Subject: Improve ability of alacritty to deal with broken config Until now alacritty completely refuses to start when the config is broken in any way. This behavior has been changed so the worst-case is always that alacritty launches with the default configuration. When part of the config is broken, alacritty shouldn't instantly try to recover to the default config, but instead try to use defaults only for the parts of the config which are broken. This has also been implemented for most of the fields in the configuration. So it should be possible that parts are broken, but the rest is still used for the configuration. This fixes #954. --- src/term/mod.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index 7e6ff1e0..72c259f7 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -444,8 +444,6 @@ pub mod mode { pub use self::mode::TermMode; -pub const TAB_SPACES: usize = 8; - trait CharsetMapping { fn map(&self, c: char) -> char { c @@ -721,6 +719,9 @@ pub struct Term { default_cursor_style: CursorStyle, dynamic_title: bool, + + /// Number of spaces in one tab + tabspaces: usize, } /// Terminal size info @@ -798,8 +799,9 @@ impl Term { let grid = Grid::new(num_lines, num_cols, &template); + let tabspaces = config.tabspaces(); let tabs = IndexRange::from(Column(0)..grid.num_cols()) - .map(|i| (*i as usize) % TAB_SPACES == 0) + .map(|i| (*i as usize) % tabspaces == 0) .collect::>(); let alt = grid.clone(); @@ -832,6 +834,7 @@ impl Term { cursor_style: None, default_cursor_style: config.cursor_style(), dynamic_title: config.dynamic_title(), + tabspaces, } } @@ -1072,7 +1075,7 @@ impl Term { // Recreate tabs list self.tabs = IndexRange::from(Column(0)..self.grid.num_cols()) - .map(|i| (*i as usize) % TAB_SPACES == 0) + .map(|i| (*i as usize) % self.tabspaces == 0) .collect::>(); if num_lines > old_lines { -- cgit v1.2.3-54-g00ecf