on master help sign in
Make gutters padding automatic (#3163)
2f98047Ivan Tham
book/src/configuration.md+1−1
@@ -38,7 +38,7 @@ hidden = false
38| `shell` | Shell to use when running external commands. | Unix: `["sh", "-c"]`<br/>Windows: `["cmd", "/C"]` |
38| `shell` | Shell to use when running external commands. | Unix: `["sh", "-c"]`<br/>Windows: `["cmd", "/C"]` |
39| `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` |
39| `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` |
40| `cursorline` | Highlight all lines with a cursor. | `false` |
40| `cursorline` | Highlight all lines with a cursor. | `false` |
41−| `gutters` | Gutters to display: Available are `diagnostics` and `line-numbers` and `padding`, note that `diagnostics` also includes other features like breakpoints | `["diagnostics", "line-numbers", "padding"]` |
41+| `gutters` | Gutters to display: Available are `diagnostics` and `line-numbers` and `padding`, note that `diagnostics` also includes other features like breakpoints, 1-width padding will be inserted if gutters is non-empty | `["diagnostics", "line-numbers", "padding"]` |
42| `auto-completion` | Enable automatic pop up of auto-completion. | `true` |
42| `auto-completion` | Enable automatic pop up of auto-completion. | `true` |
43| `auto-format` | Enable automatic formatting on save. | `true` |
43| `auto-format` | Enable automatic formatting on save. | `true` |
44| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` |
44| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` |
helix-view/src/view.rs+7−19
@@ -118,6 +118,9 @@ impl View {
118 width as usize,
118 width as usize,
119 ));
119 ));
120 }
120 }
121+ if !gutter_types.is_empty() {
122+ gutter_offset += 1;
123+ }
121 Self {
124 Self {
122 id: ViewId::default(),
125 id: ViewId::default(),
123 doc,
126 doc,
@@ -346,11 +349,7 @@ mod tests {
346 fn test_text_pos_at_screen_coords() {
349 fn test_text_pos_at_screen_coords() {
347 let mut view = View::new(
350 let mut view = View::new(
348 DocumentId::default(),
351 DocumentId::default(),
349− vec![
350− GutterType::Diagnostics,
352+ vec![GutterType::Diagnostics, GutterType::LineNumbers],
351− GutterType::LineNumbers,
352− GutterType::Padding,
353− ],
354 );
353 );
355 view.area = Rect::new(40, 40, 40, 40);
354 view.area = Rect::new(40, 40, 40, 40);
356 let rope = Rope::from_str("abc\n\tdef");
355 let rope = Rope::from_str("abc\n\tdef");
@@ -397,10 +396,7 @@ mod tests {
397
396
398 #[test]
397 #[test]
399 fn test_text_pos_at_screen_coords_without_line_numbers_gutter() {
398 fn test_text_pos_at_screen_coords_without_line_numbers_gutter() {
400− let mut view = View::new(
401− DocumentId::default(),
402− vec![GutterType::Diagnostics, GutterType::Padding],
399+ let mut view = View::new(DocumentId::default(), vec![GutterType::Diagnostics]);
403− );
404 view.area = Rect::new(40, 40, 40, 40);
400 view.area = Rect::new(40, 40, 40, 40);
405 let rope = Rope::from_str("abc\n\tdef");
401 let rope = Rope::from_str("abc\n\tdef");
406 let text = rope.slice(..);
402 let text = rope.slice(..);
@@ -426,11 +422,7 @@ mod tests {
426 fn test_text_pos_at_screen_coords_cjk() {
422 fn test_text_pos_at_screen_coords_cjk() {
427 let mut view = View::new(
423 let mut view = View::new(
428 DocumentId::default(),
424 DocumentId::default(),
429− vec![
430− GutterType::Diagnostics,
425+ vec![GutterType::Diagnostics, GutterType::LineNumbers],
431− GutterType::LineNumbers,
432− GutterType::Padding,
433− ],
434 );
426 );
435 view.area = Rect::new(40, 40, 40, 40);
427 view.area = Rect::new(40, 40, 40, 40);
436 let rope = Rope::from_str("Hi! こんにちは皆さん");
428 let rope = Rope::from_str("Hi! こんにちは皆さん");
@@ -470,11 +462,7 @@ mod tests {
470 fn test_text_pos_at_screen_coords_graphemes() {
462 fn test_text_pos_at_screen_coords_graphemes() {
471 let mut view = View::new(
463 let mut view = View::new(
472 DocumentId::default(),
464 DocumentId::default(),
473− vec![
474− GutterType::Diagnostics,
465+ vec![GutterType::Diagnostics, GutterType::LineNumbers],
475− GutterType::LineNumbers,
476− GutterType::Padding,
477− ],
478 );
466 );
479 view.area = Rect::new(40, 40, 40, 40);
467 view.area = Rect::new(40, 40, 40, 40);
480 let rope = Rope::from_str("Hèl̀l̀ò world!");
468 let rope = Rope::from_str("Hèl̀l̀ò world!");