summaryrefslogtreecommitdiff
path: root/support/texlab/src/db/document.rs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-02-26 03:02:12 +0000
committerNorbert Preining <norbert@preining.info>2023-02-26 03:02:12 +0000
commite7ae872926eddb0de09ecfe1c578e0680033955a (patch)
tree01717465b5b26d3b2ccaea9889c720a840e0a16c /support/texlab/src/db/document.rs
parent81a9d839224eef4c2bd9bf68410b4049c61cdb14 (diff)
CTAN sync 202302260302
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());
}