on master help sign in
Share tab width definitions.
commitd64f4beede412dbf77df0e00c478b053a3d6cc54 authorBlaž Hrastnik <blaz@mxxn.io> dateWed 14 Oct 2020, 12:01 (6 years ago) parent0b74d42
5 files changed+6−9
helix-core/src/indent.rs+1−1 helix-core/src/lib.rs+1−1 helix-term/src/editor.rs+1−3 helix-view/src/commands.rs+1−2 helix-view/src/view.rs+2−2
helix-core/src/indent.rs+1−1
@@ -4,7 +4,7 @@ use crate::{
44 Rope, RopeSlice, State,
55};
66
7−const TAB_WIDTH: usize = 4;
7+pub const TAB_WIDTH: usize = 4;
88
99fn indent_level_for_line(line: RopeSlice) -> usize {
1010 let mut len = 0;
helix-core/src/lib.rs+1−1
@@ -1,7 +1,7 @@
11#![allow(unused)]
22pub mod graphemes;
33mod history;
4−mod indent;
4+pub mod indent;
55pub mod macros;
66mod position;
77pub mod register;
helix-term/src/editor.rs+1−3
@@ -1,5 +1,5 @@
11use clap::ArgMatches as Args;
2−use helix_core::{state::Mode, syntax::HighlightEvent, Range, State};
2+use helix_core::{indent::TAB_WIDTH, state::Mode, syntax::HighlightEvent, Range, State};
33use helix_view::{commands, keymap, View};
44
55use std::{
@@ -24,8 +24,6 @@ use crossterm::{
2424
2525use tui::{backend::CrosstermBackend, buffer::Buffer as Surface, layout::Rect, style::Style};
2626
27−const TAB_WIDTH: usize = 4;
28−
2927type Terminal = tui::Terminal<CrosstermBackend<std::io::Stdout>>;
3028
3129static EX: smol::Executor = smol::Executor::new();
helix-view/src/commands.rs+1−2
@@ -1,5 +1,6 @@
11use helix_core::{
22 graphemes,
3+ indent::TAB_WIDTH,
34 regex::Regex,
45 register, selection,
56 state::{Direction, Granularity, Mode, State},
@@ -541,8 +542,6 @@ pub fn paste(view: &mut View, _count: usize) {
541542 }
542543}
543544
544−const TAB_WIDTH: usize = 4;
545−
546545fn get_lines(view: &View) -> Vec<usize> {
547546 let mut lines = Vec::new();
548547
helix-view/src/view.rs+2−2
@@ -5,6 +5,7 @@ use std::{borrow::Cow, path::PathBuf};
55use crate::theme::Theme;
66use helix_core::{
77 graphemes::{grapheme_width, RopeGraphemes},
8+ indent::TAB_WIDTH,
89 History, Position, RopeSlice, State,
910};
1011use tui::layout::Rect;
@@ -78,8 +79,7 @@ impl View {
7879
7980 for grapheme in RopeGraphemes::new(&line_slice) {
8081 if grapheme == "\t" {
81− // TODO: this should be const TAB_WIDTH
82− col += 4;
82+ col += TAB_WIDTH;
8383 } else {
8484 let grapheme = Cow::from(grapheme);
8585 col += grapheme_width(&grapheme);