Skip to content

Commit 5bb0acc

Browse files
committed
bangls 支持hover eval值, 支持软重复块简单补全和hover
1 parent a091764 commit 5bb0acc

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
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.13"
3+
version = "0.1.14"
44
edition = "2024"
55

66
[features]

tools/syntax/src/lib.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,7 +3071,11 @@ impl Compile for ArgsRepeat {
30713071
let count = match self.count.value {
30723072
Either::Left(0) => { set_args = false; 0 },
30733073
Either::Left(count) => count,
3074-
Either::Right(value) => {
3074+
Either::Right(mut value) => {
3075+
if let Value::Var(var) = &mut value {
3076+
meta.debug_expand_env_status(var);
3077+
meta.debug_hover_var_status(var);
3078+
}
30753079
let Some((n, _)) = value.try_eval_const_num(meta) else {
30763080
let loc = loc.location(&meta.source);
30773081
err!(loc =>
@@ -4243,7 +4247,10 @@ pub struct EmulateInfo {
42434247
pub hover_doc: Option<String>,
42444248
}
42454249

4246-
struct HoverGuard<'a> { meta: &'a mut CompileMeta, handle: Option<Var> }
4250+
struct HoverGuard<'a> {
4251+
meta: &'a mut CompileMeta,
4252+
handle: Option<Var>,
4253+
}
42474254
impl<'a> HoverGuard<'a> {
42484255
fn update_hover(&mut self, binded: Var) -> Var {
42494256
if let Some(slot) = self.handle.as_mut() {
@@ -4268,9 +4275,10 @@ impl<'a> Drop for HoverGuard<'a> {
42684275
fn drop(&mut self) {
42694276
let Some(ref var) = self.handle else { return };
42704277
let meta = &mut self.meta;
4278+
let mut valued = None;
42714279

42724280
if let Some(data) = meta.get_const_value(var) {
4273-
let display = data.value.display_src(meta).into_owned();
4281+
let display = valued.get_or_insert(data.value.display_src(meta));
42744282
meta.emulate(EmulateInfo {
42754283
hover_doc: Some(format!("Value = {display}")),
42764284
..Default::default()
@@ -4281,6 +4289,16 @@ impl<'a> Drop for HoverGuard<'a> {
42814289
..Default::default()
42824290
});
42834291
}
4292+
if let Some((num, complex)) = Value::from(var).try_eval_const_num(meta) {
4293+
let eq = if complex { "=" } else { ":=" };
4294+
let num = num.to_string();
4295+
if Some(num.as_str()) != valued.as_deref() {
4296+
meta.emulate(EmulateInfo {
4297+
hover_doc: Some(format!("Eval {eq} {num}")),
4298+
..Default::default()
4299+
});
4300+
}
4301+
}
42844302
}
42854303
}
42864304

0 commit comments

Comments
 (0)