diff options
author | Ivan Tham | 2022-07-26 01:08:09 +0000 |
---|---|---|
committer | GitHub | 2022-07-26 01:08:09 +0000 |
commit | 2f980471f816e841628cf2b75d8d8e689b3fe9d5 (patch) | |
tree | 1ad4c08e3c8fd57003513eba062507b570d111a1 /helix-view | |
parent | bfdcfec8c954225f79b49ce3e4db4bb76715ae69 (diff) |
Make gutters padding automatic (#3163)
Remove padding gutter type, and automatically add 1 padding if gutters is
non-empty.
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/view.rs | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs index e7fc16ab..6bdd5be4 100644 --- a/helix-view/src/view.rs +++ b/helix-view/src/view.rs @@ -118,6 +118,9 @@ impl View { width as usize, )); } + if !gutter_types.is_empty() { + gutter_offset += 1; + } Self { id: ViewId::default(), doc, @@ -346,11 +349,7 @@ mod tests { fn test_text_pos_at_screen_coords() { let mut view = View::new( DocumentId::default(), - vec![ - GutterType::Diagnostics, - GutterType::LineNumbers, - GutterType::Padding, - ], + vec![GutterType::Diagnostics, GutterType::LineNumbers], ); view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("abc\n\tdef"); @@ -397,10 +396,7 @@ mod tests { #[test] fn test_text_pos_at_screen_coords_without_line_numbers_gutter() { - let mut view = View::new( - DocumentId::default(), - vec![GutterType::Diagnostics, GutterType::Padding], - ); + let mut view = View::new(DocumentId::default(), vec![GutterType::Diagnostics]); view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("abc\n\tdef"); let text = rope.slice(..); @@ -426,11 +422,7 @@ mod tests { fn test_text_pos_at_screen_coords_cjk() { let mut view = View::new( DocumentId::default(), - vec![ - GutterType::Diagnostics, - GutterType::LineNumbers, - GutterType::Padding, - ], + vec![GutterType::Diagnostics, GutterType::LineNumbers], ); view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("Hi! こんにちは皆さん"); @@ -470,11 +462,7 @@ mod tests { fn test_text_pos_at_screen_coords_graphemes() { let mut view = View::new( DocumentId::default(), - vec![ - GutterType::Diagnostics, - GutterType::LineNumbers, - GutterType::Padding, - ], + vec![GutterType::Diagnostics, GutterType::LineNumbers], ); view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("Hèl̀l̀ò world!"); |