@@ -5,6 +5,7 @@ use std::path::{Component, Path, PathBuf};
55use std::sync::Arc;
66
77use helix_core::{
8+ chars::{char_is_linebreak, char_is_whitespace},
89 history::History,
910 syntax::{LanguageConfiguration, LOADER},
1011 ChangeSet, Diagnostic, Rope, Selection, State, Syntax, Transaction,
@@ -277,55 +278,6 @@ impl Document {
277278 }
278279
279280 fn detect_indent_style(&mut self) {
280− // Determine whether a character is a line break.
281− //
282− // TODO: this is probably a generally useful utility function. Where
283− // should we put it?
284− fn char_is_linebreak(c: char) -> bool {
285− [
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
293− ]
294− .contains(&c)
295− }
296−
297− // Determine whether a character qualifies as (non-line-break)
298− // whitespace.
299− //
300− // TODO: this is probably a generally useful utility function. Where
301− // should we put it?
302− //
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 {
308− match c {
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
318− => true,
319−
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,
324−
325− _ => false,
326− }
327− }
328−
329281 // Build a histogram of the indentation *increases* between
330282 // subsequent lines, ignoring lines that are all whitespace.
331283 //
@@ -689,7 +641,7 @@ impl Document {
689641 ///
690642 /// TODO: we might not need this function anymore, since the information
691643 /// is conveniently available in `Document::indent_style` now.
692− pub fn indent_unit(&self) -> &str {
644+ pub fn indent_unit(&self) -> &'static str {
693645 match self.indent_style {
694646 IndentStyle::Tabs => "\t",
695647 IndentStyle::Spaces(1) => " ",