summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-03-24 22:52:09 +0100
committerGitHub <noreply@github.com>2017-03-24 22:52:09 +0100
commit495710c3d68c3ac7c3bf762f8e4de0c2b2008b6c (patch)
treed76c58c9e140a25eba6728276dc4e7d72ed69d43 /modules/gdscript
parentbeba97c0c34bd4e88d8a1e34d26dad6c2340cc6e (diff)
parent18ab88b3f1000cbcab5704402e402e1cdf65862f (diff)
Merge pull request #8123 from bojidar-bg/gdscript-inline-block-indent
Make inline blocks in GDScript more (or less) pythonic
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gd_parser.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 6eb40d533e..1540bb51f8 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -76,7 +76,7 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) {
// be more python-like
int current = tab_level.back()->get();
- tab_level.push_back(current + 1);
+ tab_level.push_back(current);
return true;
//_set_error("newline expected after ':'.");
//return false;
@@ -2258,7 +2258,15 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
p_block->statements.push_back(nl);
#endif
+ bool is_first_line = true;
+
while (true) {
+ if (!is_first_line && tab_level.back()->prev() && tab_level.back()->prev()->get() == indent_level) {
+ // pythonic single-line expression, don't parse future lines
+ tab_level.pop_back();
+ return;
+ }
+ is_first_line = false;
GDTokenizer::Token token = tokenizer->get_token();
if (error_set)