summaryrefslogtreecommitdiff
path: root/support/texlab/src/db/document.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/src/db/document.rs')
-rw-r--r--support/texlab/src/db/document.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/support/texlab/src/db/document.rs b/support/texlab/src/db/document.rs
index 1fc7d6880c..81ed22e916 100644
--- a/support/texlab/src/db/document.rs
+++ b/support/texlab/src/db/document.rs
@@ -36,10 +36,10 @@ impl Location {
}
}
- pub fn stem<'db>(self, db: &'db dyn Db) -> Option<&'db str> {
- let name = self.uri(db).path_segments()?.last()?;
- let stem = name.rsplit_once('.').map_or(name, |(stem, _)| stem);
- Some(stem)
+ pub fn stem(self, db: &dyn Db) -> Option<String> {
+ let path = self.uri(db).to_file_path().ok()?;
+ let stem = path.file_stem()?.to_str()?;
+ Some(String::from(stem))
}
pub fn join(self, db: &dyn Db, path: &str) -> Option<Location> {
@@ -126,7 +126,7 @@ pub struct Document {
impl Document {
pub fn edit(self, db: &mut dyn Db, range: TextRange, replace_with: &str) {
let mut text = self.contents(db).set_text(db).to(String::new());
- text.replace_range(std::ops::Range::<usize>::from(range), &replace_with);
+ text.replace_range(std::ops::Range::<usize>::from(range), replace_with);
self.contents(db).set_text(db).to(text);
self.set_cursor(db).to(range.start());
}