Exclude ignored opened buffers from search

This commit is contained in:
Kirill Bulatov 2023-11-15 16:36:00 +02:00
parent ce2cfc6035
commit cafeba103b
2 changed files with 70 additions and 69 deletions

View file

@ -5570,8 +5570,16 @@ impl Project {
.iter()
.filter_map(|(_, b)| {
let buffer = b.upgrade(cx)?;
let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot());
if let Some(path) = snapshot.file().map(|file| file.path()) {
let (is_ignored, snapshot) = buffer.update(cx, |buffer, cx| {
let is_ignored = buffer
.project_path(cx)
.and_then(|path| self.entry_for_path(&path, cx))
.map_or(false, |entry| entry.is_ignored);
(is_ignored, buffer.snapshot())
});
if is_ignored && !query.include_ignored() {
return None;
} else if let Some(path) = snapshot.file().map(|file| file.path()) {
Some((path.clone(), (buffer, snapshot)))
} else {
unnamed_files.push(buffer);