Skip to content

Commit 8fc53aa

Browse files
committed
[IMP] Reuse the same functions for untitled files
1 parent 0b8f02f commit 8fc53aa

File tree

4 files changed

+146
-238
lines changed

4 files changed

+146
-238
lines changed

server/src/core/entry_point.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ impl EntryPointMgr {
258258
}
259259

260260
pub fn iter_all_but_main(&self) -> impl Iterator<Item = &Rc<RefCell<EntryPoint>>> {
261-
self.builtins_entry_points.iter().chain(
262-
self.public_entry_points.iter()).chain(
263-
self.custom_entry_points.iter()
264-
)
261+
self.builtins_entry_points.iter()
262+
.chain(self.public_entry_points.iter())
263+
.chain(self.custom_entry_points.iter())
264+
.chain(self.untitled_entry_points.iter())
265265
}
266266

267267
pub fn reset_entry_points(&mut self, with_custom_entries: bool) {
@@ -276,16 +276,9 @@ impl EntryPointMgr {
276276

277277
pub fn remove_entries_with_path(&mut self, path: &String) {
278278
for entry in self.iter_all() {
279-
if PathBuf::from(entry.borrow().path.clone()).starts_with(path) { //delete any entrypoint that would be in a subdirectory too
280-
entry.borrow_mut().to_delete = true;
281-
}
282-
}
283-
self.clean_entries();
284-
}
285-
286-
pub fn remove_untitled_entries_with_path(&mut self, path: &String) {
287-
for entry in self.untitled_entry_points.iter() {
288-
if &entry.borrow().path.clone() == path {
279+
if (entry.borrow().typ == EntryPointType::UNTITLED && entry.borrow().path == *path)
280+
|| (entry.borrow().typ != EntryPointType::UNTITLED
281+
&& PathBuf::from(entry.borrow().path.clone()).starts_with(path)){ //delete any entrypoint that would be in a subdirectory too
289282
entry.borrow_mut().to_delete = true;
290283
}
291284
}
@@ -407,7 +400,7 @@ impl EntryPoint {
407400

408401
pub fn is_valid_for(&self, path: &PathBuf) -> bool {
409402
if self.typ == EntryPointType::UNTITLED {
410-
return false;
403+
return self.path == path.sanitize();
411404
}
412405
path.starts_with(&self.path)
413406
}

0 commit comments

Comments
 (0)