Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kirawi committed Jul 14, 2021
1 parent a4b077e commit a62a34c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,14 @@ impl Document {
theme: Option<&Theme>,
config_loader: Option<&syntax::Loader>,
) -> Result<Self, Error> {
if !path.exists() {
return Ok(Self::default());
}

let mut file = std::fs::File::open(&path).context(format!("unable to open {:?}", path))?;
let (mut rope, encoding) = from_reader(&mut file, encoding)?;
let (mut rope, encoding) = if path.exists() {
let mut file = std::fs::File::open(&path).context(format!("unable to open {:?}", path))?;
from_reader(&mut file, encoding)?
} else {
(Rope::default(), encoding_rs::UTF_8)
};

let line_ending = with_line_ending(&mut rope);

let mut doc = Self::from(rope, Some(encoding));

// set the path and try detecting the language
Expand Down

0 comments on commit a62a34c

Please sign in to comment.