Apoorva Verma
aeeacf5439
Indent statements under C/C++ case labels ( #60758 )
...
# Objective
Fixes #60261
Nothing under a `case` gets indented in C or C++, and the next `case`
doesn't come back out. It stays flat until you hit `editor: format`.
## Solution
The indent queries had no rule for case labels. Added the same pair
`cpp/indents.scm` uses for `access_specifier`: open an indent range at
the label, close it at the switch's `}`, outdent on the next label.
The part that got me: `@start` uses the *end* of the node you capture.
Fine for `access_specifier`, which is just `public:`. But a
`case_statement` swallows the statements under it, so capturing the node
starts the range after the last one. Capture the `:` instead. `default:`
is a `case_statement` too, so it comes along free.
Only affects what happens after a label, so existing `case` alignment
doesn't move.
## Testing
`test_c_autoindent_switch_case` and `test_cpp_autoindent_switch_case`
cover a plain case, fall-through labels and `default`. Both fail on
main. The `access_specifier` tests still pass.
Not mine, but worth knowing: `typescript::tests::test_outline` and
`test_generator_function_outline` are flaky on main, failing about half
my full `cargo test -p languages --lib` runs with or without this
change.
## Self-Review Checklist:
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist )
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md )
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- Fixed statements under a `case` label not being indented in C and C++
([#60261 ](https://github.com/zed-industries/zed/issues/60261 )).
2026-07-12 23:02:26 +00:00
..
2026-07-10 22:51:41 +00:00
2026-06-22 09:04:29 +00:00
2026-06-09 20:13:13 +00:00
2026-05-15 12:01:31 +00:00
2026-07-10 22:51:41 +00:00
2026-07-10 11:22:16 +00:00
2026-07-10 22:51:41 +00:00
2026-06-08 14:57:47 +00:00
2026-07-10 22:51:41 +00:00
2026-06-18 20:51:36 +00:00
2026-07-10 15:01:47 +00:00
2026-06-08 09:37:00 +00:00
2026-06-05 16:49:42 +00:00
2026-07-07 10:23:28 +00:00
2026-05-01 22:33:54 +00:00
2026-06-07 16:55:18 +00:00
2026-07-07 22:20:34 +00:00
2026-06-18 02:47:10 +00:00
2026-06-01 04:40:13 +00:00
2026-07-07 06:55:29 +00:00
2026-06-23 09:13:28 +00:00
2026-06-29 20:21:46 +00:00
2026-06-30 20:10:06 +00:00
2026-07-10 22:51:41 +00:00
2026-02-25 08:12:04 +01:00
2026-07-07 23:00:12 +00:00
2026-07-06 21:27:24 +00:00
2026-07-09 12:28:59 +00:00
2026-07-06 22:12:33 +00:00
2026-07-10 12:11:57 +00:00
2026-06-29 20:21:46 +00:00
2026-06-05 10:32:57 +00:00
2026-07-02 13:23:17 +00:00
2026-06-05 10:32:57 +00:00
2026-05-29 07:06:57 +00:00
2026-06-15 03:26:51 +00:00
2026-07-03 18:24:54 +00:00
2026-06-04 22:52:29 +00:00
2026-05-28 15:00:31 +00:00
2026-07-07 10:27:57 +00:00
2026-06-17 18:29:21 +00:00
2026-04-02 17:06:57 -03:00
2026-07-08 15:54:36 +00:00
2026-06-15 10:55:39 +00:00
2026-04-29 10:27:47 +00:00
2026-04-24 10:29:51 +00:00
2026-05-13 23:35:10 +00:00
2026-06-23 09:33:47 +00:00
2026-06-02 13:29:23 +00:00
2026-07-03 18:37:06 +00:00
2026-06-27 21:19:49 +00:00
2026-07-08 20:54:51 +00:00
2026-07-09 12:28:59 +00:00
2026-07-08 12:36:29 +00:00
2026-06-24 23:28:47 +00:00
2026-06-25 14:07:41 +00:00
2026-07-06 22:12:33 +00:00
2026-07-08 12:29:04 +00:00
2026-07-12 21:46:59 +00:00
2026-06-05 19:24:28 +00:00
2026-06-23 09:33:47 +00:00
2026-04-07 12:28:19 -03:00
2026-02-28 21:47:30 -05:00
2026-06-29 15:58:53 +00:00
2026-02-19 18:57:49 +01:00
2026-02-28 22:42:19 -05:00
2026-06-24 21:32:43 +00:00
2026-07-10 11:51:16 +00:00
2026-06-07 16:39:58 +00:00
2026-07-10 11:51:16 +00:00
2026-06-23 09:33:47 +00:00
2026-07-10 22:51:41 +00:00
2026-04-18 06:34:19 +00:00
2026-05-04 06:30:47 +00:00
2026-07-08 12:10:32 +00:00
2026-07-10 09:50:19 +00:00
2026-02-19 18:57:49 +01:00
2026-06-12 12:27:28 +00:00
2026-06-12 12:27:28 +00:00
2026-07-12 21:19:11 +00:00
2026-06-15 08:48:19 +00:00
2026-07-12 21:29:44 +00:00
2026-06-16 17:42:36 +00:00
2026-07-09 12:05:50 +00:00
2026-07-12 22:46:47 +00:00
2026-07-09 18:06:00 +00:00
2026-07-12 22:46:47 +00:00
2026-07-08 15:52:48 +00:00
2026-03-24 11:05:12 +00:00
2026-04-24 08:58:26 +00:00
2026-06-16 13:47:55 +00:00
2026-06-16 13:47:55 +00:00
2026-07-08 19:22:23 +00:00
2026-07-09 05:37:35 +00:00
2026-07-09 18:06:00 +00:00
2026-07-12 23:02:26 +00:00
2026-06-16 13:47:55 +00:00
2026-06-24 01:42:52 +00:00
2026-07-01 16:55:07 +00:00
2026-06-08 21:24:44 +00:00
2026-04-22 22:22:10 +00:00
2026-06-12 12:27:28 +00:00
2026-06-22 18:20:57 +00:00
2026-05-05 22:41:13 +00:00
2026-06-25 17:30:12 +00:00
2026-07-08 12:20:52 +00:00
2026-07-12 21:46:59 +00:00
2026-06-02 13:59:39 +00:00
2026-07-07 21:59:03 +00:00
2026-07-06 08:18:50 +00:00
2026-07-09 12:05:50 +00:00
2026-07-10 15:32:21 +00:00
2026-07-09 12:05:50 +00:00
2026-03-25 12:07:34 -06:00
2026-06-23 09:33:47 +00:00
2026-07-02 11:00:16 +00:00
2026-07-12 23:02:26 +00:00
2026-06-23 09:33:47 +00:00
2026-07-03 09:50:42 +00:00
2026-07-03 09:50:42 +00:00
2026-06-29 13:24:33 +00:00
2026-07-10 15:32:21 +00:00
2026-06-28 13:48:10 +00:00
2026-07-09 11:05:04 +00:00
2026-07-12 22:11:56 +00:00
2026-06-22 15:42:12 +00:00
2026-07-08 16:53:11 +00:00
2026-06-02 12:03:05 +00:00
2026-06-02 13:29:23 +00:00
2026-07-08 12:29:04 +00:00
2026-02-20 13:36:04 +00:00
2026-07-12 22:23:53 +00:00
2026-05-29 07:06:57 +00:00
2026-05-14 21:03:56 +00:00
2026-06-23 09:21:31 +00:00
2026-07-06 11:37:43 +00:00
2026-07-09 17:37:43 +00:00
2026-06-23 09:33:47 +00:00
2026-06-23 23:01:58 +00:00
2026-07-07 10:16:42 +00:00
2026-06-23 09:33:47 +00:00
2026-07-08 12:10:32 +00:00
2026-05-12 15:52:52 +00:00
2026-05-14 16:30:08 +00:00
2026-07-10 16:52:14 +00:00
2026-07-03 10:48:15 +00:00
2026-06-10 12:02:29 +00:00
2026-06-13 05:21:05 +00:00
2026-07-10 12:11:57 +00:00
2026-05-05 22:41:13 +00:00
2026-07-09 12:32:00 +00:00
2026-07-03 10:48:15 +00:00
2026-06-05 19:46:05 +00:00
2026-07-10 12:11:57 +00:00
2026-06-25 10:56:11 +00:00
2026-05-15 21:17:43 +00:00
2026-07-08 12:20:52 +00:00
2026-04-16 16:36:09 -07:00
2026-07-10 12:11:57 +00:00
2026-06-23 09:33:47 +00:00
2026-07-03 01:00:54 +00:00
2026-05-27 10:31:53 +00:00
2026-06-05 10:32:57 +00:00
2026-07-10 22:51:41 +00:00
2026-06-08 15:44:17 +00:00
2026-03-27 14:41:25 +01:00
2026-07-12 22:26:11 +00:00
2026-07-07 11:48:14 +00:00
2026-07-08 16:53:11 +00:00
2026-07-11 13:36:18 +00:00
2026-03-25 12:07:34 -06:00
2026-06-23 09:33:47 +00:00
2026-07-12 21:48:38 +00:00
2026-05-05 16:25:56 +00:00
2026-06-23 14:40:13 +00:00
2026-04-29 10:27:47 +00:00
2026-06-23 09:33:47 +00:00
2026-04-24 10:29:51 +00:00
2026-05-27 19:33:04 +00:00
2026-05-27 10:31:53 +00:00
2026-03-29 14:43:05 +00:00
2026-03-31 08:06:37 -06:00
2026-05-04 06:30:47 +00:00
2026-06-23 09:33:47 +00:00
2026-06-09 22:46:22 +00:00
2026-06-23 09:33:47 +00:00
2026-07-11 22:14:52 +00:00
2026-07-11 20:03:03 +00:00
2026-06-09 20:13:13 +00:00
2026-07-01 17:36:23 +00:00
2026-03-27 14:41:25 +01:00
2026-03-27 14:41:25 +01:00
2026-06-23 09:33:47 +00:00
2026-07-02 05:04:24 +00:00
2026-05-28 19:43:30 +00:00
2026-07-06 19:47:57 +00:00
2026-06-23 09:33:47 +00:00
2026-07-07 12:15:07 +00:00
2026-07-01 04:25:40 +00:00
2026-05-29 07:06:57 +00:00
2026-06-08 14:59:39 +00:00
2026-06-29 15:58:53 +00:00
2026-07-08 14:19:58 +00:00
2026-03-19 12:53:26 -04:00
2026-05-27 10:31:53 +00:00
2026-06-09 12:06:49 +00:00
2026-03-27 14:41:25 +01:00
2026-05-01 22:33:54 +00:00
2026-07-08 15:52:48 +00:00
2026-07-12 22:26:11 +00:00
2026-02-19 18:57:49 +01:00
2026-05-29 16:28:27 +00:00
2026-07-12 22:46:47 +00:00
2026-07-07 14:38:47 +00:00
2026-04-02 17:06:57 -03:00
2026-04-02 17:06:57 -03:00
2026-07-08 12:10:32 +00:00
2026-07-01 15:18:54 +00:00
2026-05-28 20:19:17 +00:00
2026-05-28 20:19:17 +00:00