@@ -5,6 +5,7 @@ use std::path::{Component, Path, PathBuf};
5use std::sync::Arc;
5use std::sync::Arc;
7use helix_core::{
7use helix_core::{
8+ chars::{char_is_linebreak, char_is_whitespace},
8 history::History,
9 history::History,
9 syntax::{LanguageConfiguration, LOADER},
10 syntax::{LanguageConfiguration, LOADER},
10 ChangeSet, Diagnostic, Rope, Selection, State, Syntax, Transaction,
11 ChangeSet, Diagnostic, Rope, Selection, State, Syntax, Transaction,
@@ -277,55 +278,6 @@ impl Document {
279 fn detect_indent_style(&mut self) {
280 fn detect_indent_style(&mut self) {
280− // Determine whether a character is a line break.
282− // TODO: this is probably a generally useful utility function. Where
283− // should we put it?
284− fn char_is_linebreak(c: char) -> bool {
286− '\u{000A}', // LineFeed
287− '\u{000B}', // VerticalTab
288− '\u{000C}', // FormFeed
289− '\u{000D}', // CarriageReturn
290− '\u{0085}', // NextLine
291− '\u{2028}', // Line Separator
292− '\u{2029}', // ParagraphSeparator
297− // Determine whether a character qualifies as (non-line-break)
300− // TODO: this is probably a generally useful utility function. Where
301− // should we put it?
303− // TODO: this is a naive binary categorization of whitespace
304− // characters. For display, word wrapping, etc. we'll need a better
305− // categorization based on e.g. breaking vs non-breaking spaces
306− // and whether they're zero-width or not.
307− pub fn char_is_whitespace(c: char) -> bool {
309− //'\u{1680}' | // Ogham Space Mark (here for completeness, but usually displayed as a dash, not as whitespace)
310− '\u{0009}' | // Character Tabulation
311− '\u{0020}' | // Space
312− '\u{00A0}' | // No-break Space
313− '\u{180E}' | // Mongolian Vowel Separator
314− '\u{202F}' | // Narrow No-break Space
315− '\u{205F}' | // Medium Mathematical Space
316− '\u{3000}' | // Ideographic Space
317− '\u{FEFF}' // Zero Width No-break Space
320− // En Quad, Em Quad, En Space, Em Space, Three-per-em Space,
321− // Four-per-em Space, Six-per-em Space, Figure Space,
322− // Punctuation Space, Thin Space, Hair Space, Zero Width Space.
323− c if ('\u{2000}' ..= '\u{200B}').contains(&c) => true,
329 // Build a histogram of the indentation *increases* between
281 // Build a histogram of the indentation *increases* between
330 // subsequent lines, ignoring lines that are all whitespace.
282 // subsequent lines, ignoring lines that are all whitespace.
@@ -689,7 +641,7 @@ impl Document {
690 /// TODO: we might not need this function anymore, since the information
642 /// TODO: we might not need this function anymore, since the information
691 /// is conveniently available in `Document::indent_style` now.
643 /// is conveniently available in `Document::indent_style` now.
692− pub fn indent_unit(&self) -> &str {
644+ pub fn indent_unit(&self) -> &'static str {
693 match self.indent_style {
645 match self.indent_style {
694 IndentStyle::Tabs => "\t",
646 IndentStyle::Tabs => "\t",
695 IndentStyle::Spaces(1) => " ",
647 IndentStyle::Spaces(1) => " ",