diff --git a/.vscode/launch.json b/.vscode/launch.json index 4255c8029..b61869bef 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -64,7 +64,7 @@ "type": "lldb", "request": "attach", "name": "debug lsp", - "program": "plc", + "pid": "${command:pickProcess}" }, { "type": "lldb", diff --git a/planglib/std/future/delay.pi b/planglib/std/future/delay.pi index d7dd553a1..03d7daabe 100644 --- a/planglib/std/future/delay.pi +++ b/planglib/std/future/delay.pi @@ -22,11 +22,11 @@ impl Future<()> for Delay{ thread::spawn(||=>{ let sec = self.sec - (unixtime() - self.start); if sec <= 0 { - wk.wake(wk.ch); + wk.wake(); return; } thread::sleep(sec); - wk.wake(wk.ch); + wk.wake(); return; }); return Pending{}; diff --git a/planglib/std/future/executor.pi b/planglib/std/future/executor.pi index 60a796565..5992a15d8 100644 --- a/planglib/std/future/executor.pi +++ b/planglib/std/future/executor.pi @@ -21,11 +21,10 @@ impl Executor { while true { let work: |Waker|=>void = self.ch.recv(); let waker = Waker{ - wake: |ch| => void { - ch.send(work); + wake: || => void { + self.ch.send(work); return; }, - ch: self.ch, }; work(waker); } diff --git a/planglib/std/future/primitives.pi b/planglib/std/future/primitives.pi index 69cc1acf3..7a49edc26 100644 --- a/planglib/std/future/primitives.pi +++ b/planglib/std/future/primitives.pi @@ -1,7 +1,6 @@ use std::chan; pub struct Waker { - pub wake:|*chan::Chan<|Waker|=>void>|=>void; - pub ch:*chan::Chan<|Waker|=>void>; + pub wake:||=>void; } pub struct Pending {} @@ -39,30 +38,28 @@ impl Future for FnFuture { use std::io; + impl FutureExt for Future { fn continue_with(f:|T|=>Future) Future { let re = Pending{} as Poll; let ff = FnFuture{}; ff.re = re; ff.f = |wk:Waker|=> { - let re = self.poll(Waker{wake:|ch|=>{ + let re = self.poll(Waker{wake:||=>{ let re = self.poll(Waker{}) as Ready!; - - ch.send(|_wk:Waker|=>{ - let re1 = f(re.v); - let result = re1.poll(wk); - ff.re = result; - if result is Ready{ - wk.wake(wk.ch); - } - return; - }); - + let re1 = f(re.v); + let result = re1.poll(wk); + ff.re = result; + if result is Ready{ + wk.wake(); + } return; - },ch:wk.ch}); + }}); if re is Ready { let re = f((re as Ready!).v); - return re.poll(wk); + let result = re.poll(wk); + ff.re = result; + return result; } return Pending{} as Poll; }; diff --git a/src/ast/ctx/lsp.rs b/src/ast/ctx/lsp.rs index 2c3f1b17d..d84b4fddf 100644 --- a/src/ast/ctx/lsp.rs +++ b/src/ast/ctx/lsp.rs @@ -120,7 +120,8 @@ impl Ctx<'_> { .push(range.to_diag_range(), type_index(tp), modifiers) } pub fn push_type_hints(&self, range: Range, pltype: Arc>) { - if self.need_highlight.borrow().ne(&0) || self.in_macro { + let ori_mod = unsafe { &*self.origin_mod as &crate::ast::plmod::Mod }; + if self.need_highlight.borrow().ne(&0) || self.in_macro || ori_mod.path != self.plmod.path { return; } let colon = InlayHintLabelPart { @@ -151,7 +152,8 @@ impl Ctx<'_> { self.plmod.hints.borrow_mut().push(hint); } pub fn push_param_hint(&self, range: Range, name: Ustr) { - if self.need_highlight.borrow().ne(&0) || self.in_macro { + let ori_mod = unsafe { &*self.origin_mod as &crate::ast::plmod::Mod }; + if self.need_highlight.borrow().ne(&0) || self.in_macro || ori_mod.path != self.plmod.path { return; } let hint = InlayHint { diff --git a/test/test/future_test.pi b/test/test/future_test.pi index 59df18e6f..22758e17e 100644 --- a/test/test/future_test.pi +++ b/test/test/future_test.pi @@ -13,12 +13,18 @@ pub fn test_future() void { let ff1 = f.continue_with(|r:()| => { println!("Hello from future"); return future::nothing_future(); + }).continue_with(|r:()| => { + println!("continue Hello from future"); + return future::nothing_future(); }); let f2:future::Future<()> = future::delay(1 as u64); let ff2 = f2.continue_with(|r:()| => { println!("Hello from future2"); return future::nothing_future(); + }).continue_with(|r:()| => { + println!("continue Hello from future2"); + return future::nothing_future(); }); exe.spawn(ff1); exe.spawn(ff2);