diff --git a/book/src/configuration.md b/book/src/configuration.md index 5eb94c4e942b..cc760a66424e 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -38,7 +38,7 @@ hidden = false | `shell` | Shell to use when running external commands. | Unix: `["sh", "-c"]`
Windows: `["cmd", "/C"]` | | `line-number` | Line number display: `absolute` simply shows each line's number, while `relative` shows the distance from the current line. When unfocused or in insert mode, `relative` will still show absolute line numbers. | `absolute` | | `cursorline` | Highlight all lines with a cursor. | `false` | -| `gutters` | Gutters to display: Available are `diagnostics` and `line-numbers` and `spacer`, note that `diagnostics` also includes other features like breakpoints, 1-width padding will be inserted if gutters is non-empty | `["diagnostics", "line-numbers"]` | +| `gutters` | Gutters to display: Available are `diagnostics` and `line-numbers` and `spacer`, note that `diagnostics` also includes other features like breakpoints. | `["diagnostics", "line-numbers", "spacer"]` | | `auto-completion` | Enable automatic pop up of auto-completion. | `true` | | `auto-format` | Enable automatic formatting on save. | `true` | | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 501c3069ad19..6b5616b7f370 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -481,7 +481,11 @@ impl Default for Config { }, line_number: LineNumber::Absolute, cursorline: false, - gutters: vec![GutterType::Diagnostics, GutterType::LineNumbers], + gutters: vec![ + GutterType::Diagnostics, + GutterType::LineNumbers, + GutterType::Spacer, + ], middle_click_paste: true, auto_pairs: AutoPairConfig::default(), auto_completion: true, diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs index 3df533dfc6d9..06c2976874cf 100644 --- a/helix-view/src/view.rs +++ b/helix-view/src/view.rs @@ -118,9 +118,6 @@ impl View { width as usize, )); } - if !gutter_types.is_empty() { - gutter_offset += 1; - } Self { id: ViewId::default(), doc, @@ -340,16 +337,20 @@ impl View { mod tests { use super::*; use helix_core::Rope; - const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter - const OFFSET_WITHOUT_LINE_NUMBERS: u16 = 2; // 1 diagnostic + 1 gutter - // const OFFSET: u16 = GUTTERS.iter().map(|(_, width)| *width as u16).sum(); + const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 spacer + const OFFSET_WITHOUT_LINE_NUMBERS: u16 = 1; // 1 diagnostic + use crate::editor::GutterType; #[test] fn test_text_pos_at_screen_coords() { let mut view = View::new( DocumentId::default(), - vec![GutterType::Diagnostics, GutterType::LineNumbers], + vec![ + GutterType::Diagnostics, + GutterType::LineNumbers, + GutterType::Spacer, + ], ); view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("abc\n\tdef"); @@ -422,7 +423,11 @@ mod tests { fn test_text_pos_at_screen_coords_cjk() { let mut view = View::new( DocumentId::default(), - vec![GutterType::Diagnostics, GutterType::LineNumbers], + vec![ + GutterType::Diagnostics, + GutterType::LineNumbers, + GutterType::Spacer, + ], ); view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("Hi! こんにちは皆さん"); @@ -462,7 +467,11 @@ mod tests { fn test_text_pos_at_screen_coords_graphemes() { let mut view = View::new( DocumentId::default(), - vec![GutterType::Diagnostics, GutterType::LineNumbers], + vec![ + GutterType::Diagnostics, + GutterType::LineNumbers, + GutterType::Spacer, + ], ); view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("Hèl̀l̀ò world!");