on master help sign in
Share tab width definitions.
d64f4beBlaž Hrastnik
helix-core/src/indent.rs+1−1
@@ -4,7 +4,7 @@ use crate::{
4 Rope, RopeSlice, State,
4 Rope, RopeSlice, State,
5};
5};
6
6
7−const TAB_WIDTH: usize = 4;
7+pub const TAB_WIDTH: usize = 4;
8
8
9fn indent_level_for_line(line: RopeSlice) -> usize {
9fn indent_level_for_line(line: RopeSlice) -> usize {
10 let mut len = 0;
10 let mut len = 0;
helix-core/src/lib.rs+1−1
@@ -1,7 +1,7 @@
1#![allow(unused)]
1#![allow(unused)]
2pub mod graphemes;
2pub mod graphemes;
3mod history;
3mod history;
4−mod indent;
4+pub mod indent;
5pub mod macros;
5pub mod macros;
6mod position;
6mod position;
7pub mod register;
7pub mod register;
helix-term/src/editor.rs+1−3
@@ -1,5 +1,5 @@
1use clap::ArgMatches as Args;
1use 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};
3use helix_view::{commands, keymap, View};
3use helix_view::{commands, keymap, View};
4
4
5use std::{
5use std::{
@@ -24,8 +24,6 @@ use crossterm::{
24
24
25use tui::{backend::CrosstermBackend, buffer::Buffer as Surface, layout::Rect, style::Style};
25use tui::{backend::CrosstermBackend, buffer::Buffer as Surface, layout::Rect, style::Style};
26
26
27−const TAB_WIDTH: usize = 4;
28−
29type Terminal = tui::Terminal<CrosstermBackend<std::io::Stdout>>;
27type Terminal = tui::Terminal<CrosstermBackend<std::io::Stdout>>;
30
28
31static EX: smol::Executor = smol::Executor::new();
29static EX: smol::Executor = smol::Executor::new();
helix-view/src/commands.rs+1−2
@@ -1,5 +1,6 @@
1use helix_core::{
1use helix_core::{
2 graphemes,
2 graphemes,
3+ indent::TAB_WIDTH,
3 regex::Regex,
4 regex::Regex,
4 register, selection,
5 register, selection,
5 state::{Direction, Granularity, Mode, State},
6 state::{Direction, Granularity, Mode, State},
@@ -541,8 +542,6 @@ pub fn paste(view: &mut View, _count: usize) {
541 }
542 }
542}
543}
543
544
544−const TAB_WIDTH: usize = 4;
545−
546fn get_lines(view: &View) -> Vec<usize> {
545fn get_lines(view: &View) -> Vec<usize> {
547 let mut lines = Vec::new();
546 let mut lines = Vec::new();
548
547
helix-view/src/view.rs+2−2
@@ -5,6 +5,7 @@ use std::{borrow::Cow, path::PathBuf};
5use crate::theme::Theme;
5use crate::theme::Theme;
6use helix_core::{
6use helix_core::{
7 graphemes::{grapheme_width, RopeGraphemes},
7 graphemes::{grapheme_width, RopeGraphemes},
8+ indent::TAB_WIDTH,
8 History, Position, RopeSlice, State,
9 History, Position, RopeSlice, State,
9};
10};
10use tui::layout::Rect;
11use tui::layout::Rect;
@@ -78,8 +79,7 @@ impl View {
78
79
79 for grapheme in RopeGraphemes::new(&line_slice) {
80 for grapheme in RopeGraphemes::new(&line_slice) {
80 if grapheme == "\t" {
81 if grapheme == "\t" {
81− // TODO: this should be const TAB_WIDTH
82+ col += TAB_WIDTH;
82− col += 4;
83 } else {
83 } else {
84 let grapheme = Cow::from(grapheme);
84 let grapheme = Cow::from(grapheme);
85 col += grapheme_width(&grapheme);
85 col += grapheme_width(&grapheme);