Skip to content

Commit

Permalink
undo change, no magically added space please, just add Spacer by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiko Mastboom committed Aug 1, 2022
1 parent 07019c3 commit e365f5e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ hidden = false
| `shell` | Shell to use when running external commands. | Unix: `["sh", "-c"]`<br/>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` |
Expand Down
6 changes: 5 additions & 1 deletion helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
27 changes: 18 additions & 9 deletions helix-view/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ impl View {
width as usize,
));
}
if !gutter_types.is_empty() {
gutter_offset += 1;
}
Self {
id: ViewId::default(),
doc,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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! こんにちは皆さん");
Expand Down Expand Up @@ -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!");
Expand Down

0 comments on commit e365f5e

Please sign in to comment.