|
|
@ -708,7 +708,7 @@ impl Document {
|
|
|
|
let mut doc = Self::from(rope, Some((encoding, has_bom)), config);
|
|
|
|
let mut doc = Self::from(rope, Some((encoding, has_bom)), config);
|
|
|
|
|
|
|
|
|
|
|
|
// set the path and try detecting the language
|
|
|
|
// set the path and try detecting the language
|
|
|
|
doc.set_path(Some(path))?;
|
|
|
|
doc.set_path(Some(path));
|
|
|
|
if let Some(loader) = config_loader {
|
|
|
|
if let Some(loader) = config_loader {
|
|
|
|
doc.detect_language(loader);
|
|
|
|
doc.detect_language(loader);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -853,7 +853,7 @@ impl Document {
|
|
|
|
let text = self.text().clone();
|
|
|
|
let text = self.text().clone();
|
|
|
|
|
|
|
|
|
|
|
|
let path = match path {
|
|
|
|
let path = match path {
|
|
|
|
Some(path) => helix_core::path::get_canonicalized_path(&path)?,
|
|
|
|
Some(path) => helix_core::path::get_canonicalized_path(&path),
|
|
|
|
None => {
|
|
|
|
None => {
|
|
|
|
if self.path.is_none() {
|
|
|
|
if self.path.is_none() {
|
|
|
|
bail!("Can't save with no path set!");
|
|
|
|
bail!("Can't save with no path set!");
|
|
|
@ -1047,18 +1047,14 @@ impl Document {
|
|
|
|
self.encoding
|
|
|
|
self.encoding
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn set_path(&mut self, path: Option<&Path>) -> Result<(), std::io::Error> {
|
|
|
|
pub fn set_path(&mut self, path: Option<&Path>) {
|
|
|
|
let path = path
|
|
|
|
let path = path.map(helix_core::path::get_canonicalized_path);
|
|
|
|
.map(helix_core::path::get_canonicalized_path)
|
|
|
|
|
|
|
|
.transpose()?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if parent doesn't exist we still want to open the document
|
|
|
|
// if parent doesn't exist we still want to open the document
|
|
|
|
// and error out when document is saved
|
|
|
|
// and error out when document is saved
|
|
|
|
self.path = path;
|
|
|
|
self.path = path;
|
|
|
|
|
|
|
|
|
|
|
|
self.detect_readonly();
|
|
|
|
self.detect_readonly();
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Set the programming language for the file and load associated data (e.g. highlighting)
|
|
|
|
/// Set the programming language for the file and load associated data (e.g. highlighting)
|
|
|
|