diff --git a/runtime/queries/c/indents.scm b/runtime/queries/c/indents.scm index 877b6670..fde2231f 100644 --- a/runtime/queries/c/indents.scm +++ b/runtime/queries/c/indents.scm @@ -10,6 +10,7 @@ [ "case" + "default" "}" "]" ")" diff --git a/runtime/queries/dart/indents.scm b/runtime/queries/dart/indents.scm index cdb96ae8..2681605b 100644 --- a/runtime/queries/dart/indents.scm +++ b/runtime/queries/dart/indents.scm @@ -9,6 +9,10 @@ (block) (assertion_arguments) (switch_block) + ; statements after a `case`/`default` label (the node also holds the label, + ; so the default tail scope indents only the body lines, not the label) + (switch_statement_case) + (switch_statement_default) (catch_parameters) (for_loop_parts) (configuration_uri_condition) diff --git a/runtime/queries/java/indents.scm b/runtime/queries/java/indents.scm index 76e21861..6b43e7b8 100644 --- a/runtime/queries/java/indents.scm +++ b/runtime/queries/java/indents.scm @@ -7,6 +7,9 @@ (module_body) (block) (switch_block) + ; statements after a `case`/`default` label (the group also holds the label, + ; so the default tail scope indents only the body lines, not the label) + (switch_block_statement_group) (array_initializer) (argument_list) (formal_parameters) diff --git a/runtime/queries/php/indents.scm b/runtime/queries/php/indents.scm index 1af1b21b..b6d1f546 100644 --- a/runtime/queries/php/indents.scm +++ b/runtime/queries/php/indents.scm @@ -8,6 +8,10 @@ (return_statement) (expression_statement) (switch_block) + ; statements after a `case`/`default` label (the node also holds the label, + ; so the default tail scope indents only the body lines, not the label) + (case_statement) + (default_statement) (anonymous_function_use_clause) (property_hook_list) ] @indent diff --git a/runtime/queries/slang/indents.scm b/runtime/queries/slang/indents.scm index 75ed7a93..c3a77f0d 100644 --- a/runtime/queries/slang/indents.scm +++ b/runtime/queries/slang/indents.scm @@ -1,4 +1,4 @@ -; inherits: hlsl +; inherits: c [ (interface_specifier) diff --git a/runtime/queries/swift/indents.scm b/runtime/queries/swift/indents.scm index 33ce5535..a1618741 100644 --- a/runtime/queries/swift/indents.scm +++ b/runtime/queries/swift/indents.scm @@ -58,11 +58,14 @@ (if_statement) @outdent ) -(switch_entry - . - _ @indent - (#set! "scope" "tail") -) +; switch_entry wraps both the case/default label and the body statements. The +; default tail scope indents the lines after the label (the body) without +; indenting the label itself, and because switch_entry is an ancestor of the +; cursor whether reindenting a body line or typing a newline after the label, +; it resolves correctly in both indent directions (capturing the inner +; (statements) node only works when reindenting; capturing the label only works +; when typing — the wrapper handles both). +(switch_entry) @indent (init_declaration (parameter) @indent