-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multi-line if-then-else
#6408
Comments
Will need some help from @kazcw |
To debug the tests one has to:
The handling of enso$ git diff lib/rust/parser/debug/tests/parse.rs
diff --git lib/rust/parser/debug/tests/parse.rs lib/rust/parser/debug/tests/parse.rs
index 4a22c36cc5..e6470a4eae 100644
--- lib/rust/parser/debug/tests/parse.rs
+++ lib/rust/parser/debug/tests/parse.rs
@@ -102,6 +102,23 @@ fn else_block() {
((Ident else) (BodyBlock #((Ident False))))))]);
}
+#[test]
+fn true_else_blocks() {
+ #[rustfmt::skip]
+ let lines = vec![
+ "if True then",
+ " 0",
+ "else",
+ " 1",
+ ];
+ let text = &lines.join("\n");
+ let expected = block![
+ (MultiSegmentApp #(((Ident if) (Ident True))
+ ((Ident then) (BodyBlock #((Number () "0" ()))))
+ ((Ident else) (BodyBlock #((Number () "0" ()))))))];
+ test(text, expected);
+}
+
// === Comments ===
triggers just the
I got an idea to disable the enso$ git diff lib/rust/parser/src/macros/built_in.rs
diff --git lib/rust/parser/src/macros/built_in.rs lib/rust/parser/src/macros/built_in.rs
index 1f789687af..b6eecb4c8c 100644
--- lib/rust/parser/src/macros/built_in.rs
+++ lib/rust/parser/src/macros/built_in.rs
@@ -19,7 +19,7 @@ pub fn all() -> resolver::MacroMap {
/// Built-in macro definitions that match anywhere in an expression.
fn expression() -> resolver::SegmentMap<'static> {
let mut macro_map = resolver::SegmentMap::default();
- macro_map.register(if_then());
+// macro_map.register(if_then());
macro_map.register(if_then_else());
macro_map.register(group());
macro_map.register(lambda()); that prevents the first line to be recognized as |
Just adding to that to clarify that if possible it would be best to also be able to 'chain' multiple conditions without introducing additional indentation, e.g.:
|
Currently we can do:
or
It would be good to allow:
(we currently do this by using
case a=b of
to achieve similar results).The text was updated successfully, but these errors were encountered: