@@ -5,14 +5,10 @@ use std::path::{Component, Path, PathBuf};
5use std::sync::Arc;
5use std::sync::Arc;
7use helix_core::{
7use helix_core::{
9 chars::{char_is_linebreak, char_is_whitespace},
8 chars::{char_is_linebreak, char_is_whitespace},
10− history::History,
9+ auto_detect_line_ending, DEFAULT_LINE_ENDING, history::History,
12− auto_detect_line_ending, default_line_ending,
13−>>>>>>> 491a8b3 (resolved conflict in rebase)
14 syntax::{LanguageConfiguration, LOADER},
10 syntax::{LanguageConfiguration, LOADER},
15− ChangeSet, Diagnostic, History, LineEnding, Rope, Selection, State, Syntax, Transaction,
11+ ChangeSet, Diagnostic, LineEnding, Rope, Selection, State, Syntax, Transaction,
18use crate::{DocumentId, ViewId};
14use crate::{DocumentId, ViewId};
@@ -26,8 +22,6 @@ pub enum Mode {
31#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
25#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
32pub enum IndentStyle {
26pub enum IndentStyle {
@@ -49,8 +43,6 @@ pub enum LineEnding {
49 PS = 8, // U+2029 -- ParagraphSeparator
43 PS = 8, // U+2029 -- ParagraphSeparator
53−>>>>>>> 491a8b3 (resolved conflict in rebase)
54pub struct Document {
46pub struct Document {
55 // rope + selection
47 // rope + selection
56 pub(crate) id: DocumentId,
48 pub(crate) id: DocumentId,
@@ -84,7 +76,7 @@ pub struct Document {
85 diagnostics: Vec<Diagnostic>,
77 diagnostics: Vec<Diagnostic>,
86 language_server: Option<Arc<helix_lsp::Client>>,
78 language_server: Option<Arc<helix_lsp::Client>>,
87− line_ending: Option<LineEnding>,
79+ line_ending: LineEnding,
90use std::fmt;
82use std::fmt;
@@ -177,7 +169,6 @@ impl Document {
177 pub fn new(text: Rope) -> Self {
169 pub fn new(text: Rope) -> Self {
178 let changes = ChangeSet::new(&text);
170 let changes = ChangeSet::new(&text);
179 let old_state = None;
171 let old_state = None;
180− let line_ending = default_line_ending();
183 id: DocumentId::default(),
174 id: DocumentId::default(),
@@ -196,7 +187,7 @@ impl Document {
196 history: Cell::new(History::default()),
187 history: Cell::new(History::default()),
197 last_saved_revision: 0,
188 last_saved_revision: 0,
198 language_server: None,
189 language_server: None,
199− line_ending,
190+ line_ending: DEFAULT_LINE_ENDING,
@@ -217,16 +208,13 @@ impl Document {
219 // search for line endings
210 // search for line endings
220− let line_ending = auto_detect_line_ending(&doc);
211+ let line_ending = auto_detect_line_ending(&doc).unwrap_or(DEFAULT_LINE_ENDING);
222 let mut doc = Self::new(doc);
213 let mut doc = Self::new(doc);
223 // set the path and try detecting the language
214 // set the path and try detecting the language
224 doc.set_path(&path)?;
215 doc.set_path(&path)?;
226 doc.detect_indent_style();
216 doc.detect_indent_style();
228 doc.set_line_ending(line_ending);
217 doc.set_line_ending(line_ending);
229−>>>>>>> 491a8b3 (resolved conflict in rebase)
@@ -485,7 +473,7 @@ impl Document {
485 self.selections.insert(view_id, selection);
473 self.selections.insert(view_id, selection);
488− pub fn set_line_ending(&mut self, line_ending: Option<LineEnding>) {
476+ pub fn set_line_ending(&mut self, line_ending: LineEnding) {
489 self.line_ending = line_ending;
477 self.line_ending = line_ending;