From 823b3928a17381bcd1723d0b04e5ab2611529bca Mon Sep 17 00:00:00 2001 From: Daniel Ebert Date: Wed, 28 Dec 2022 22:55:00 +0100 Subject: [PATCH] Improve indent queries for python in specific cases where the tree-sitter completely fails to parse incomplete code. --- runtime/queries/python/indents.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/runtime/queries/python/indents.scm b/runtime/queries/python/indents.scm index 743971adb8d2..835b40d394c3 100644 --- a/runtime/queries/python/indents.scm +++ b/runtime/queries/python/indents.scm @@ -29,6 +29,19 @@ (class_definition) ] @indent +; Workaround for the tree-sitter grammar creating large errors when a +; try_statement is missing the except/finally clause +(ERROR + "try" + . + ":" @indent @extend) +(ERROR + . + "def") @indent @extend +(ERROR + (block) @indent @extend + (#set! "scope" "all")) + [ (if_statement) (for_statement)