Skip to content

Commit 80b9d77

Browse files
committed
修复 Diagnostics 导致的可选补全假阳性
1 parent 604b5c1 commit 80b9d77

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/bangls/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bangls"
3-
version = "0.1.7"
3+
version = "0.1.8"
44
edition = "2024"
55

66
[features]

tools/bangls/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ impl RequestHandler for request::DocumentDiagnosticRequest {
318318
}
319319

320320
fn generate_completes(infos: &[EmulateInfo]) -> Vec<CompletionItem> {
321+
let infos = infos.iter()
322+
.filter_map(|it| it.exist_vars.as_ref());
323+
let full_count = infos.clone().count() as u32;
321324
let mut var_counter: LinkedHashMap<&syntax::Var, (u32, Vec<_>)> = LinkedHashMap::new();
322325
for info in infos {
323-
for (kind, var) in info.exist_vars.iter() {
326+
for (kind, var) in info {
324327
if var.starts_with("__") {
325328
continue;
326329
}
@@ -329,7 +332,6 @@ fn generate_completes(infos: &[EmulateInfo]) -> Vec<CompletionItem> {
329332
kinds.push(kind);
330333
}
331334
}
332-
let full_count = infos.len() as u32;
333335
var_counter.iter().map(|(&var, &(count, ref kinds))| {
334336
let is_full_deps = count == full_count;
335337

tools/syntax/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4193,7 +4193,7 @@ pub enum Emulate {
41934193

41944194
#[derive(Debug, Default)]
41954195
pub struct EmulateInfo {
4196-
pub exist_vars: Vec<(Emulate, Var)>,
4196+
pub exist_vars: Option<Vec<(Emulate, Var)>>,
41974197
pub location: Option<(u32, u32)>,
41984198
pub diagnostic: Option<String>,
41994199
pub is_error: bool,
@@ -4536,7 +4536,7 @@ impl CompileMeta {
45364536
.for_each(|(kind, var)| if printed.insert(var) {
45374537
vars.push((kind, var.clone()));
45384538
});
4539-
self.emulate(EmulateInfo { exist_vars: vars, ..Default::default() });
4539+
self.emulate(EmulateInfo { exist_vars: Some(vars), ..Default::default() });
45404540
}
45414541

45424542
fn debug_hover_var_status(&mut self, var: &mut Var) -> HoverGuard<'_> {
@@ -4573,7 +4573,7 @@ impl CompileMeta {
45734573
}
45744574
bind_vars
45754575
});
4576-
self.emulate(EmulateInfo { exist_vars: bind_vars, ..Default::default() });
4576+
self.emulate(EmulateInfo { exist_vars: Some(bind_vars), ..Default::default() });
45774577
}
45784578

45794579
/// 进入一个拥有子命名空间的子块

0 commit comments

Comments
 (0)