# Fix hard-tab block autoindent skipping unindented lines \(\#60406\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/d9ada8487bca20be32c7621e296030c9d68362f5)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: d9ada8487bca20be32c7621e296030c9d68362f5

Requested commit: d9ada8487bca20be32c7621e296030c9d68362f5

Commit: d9ada8487bca20be32c7621e296030c9d68362f5

Tree: 422ceeba834cc70036024ba97a4120e694ac5b85

Author: Apoorva Verma

Committer: GitHub

## Message

```
Fix hard-tab block autoindent skipping unindented lines (#60406)

# Objective

Fixes #59979

With hard tabs on, expanding a multi-line snippet only re-indents the
lines that already start with a tab. Anything with no leading whitespace
(closing brackets, mostly) stays at column 0.

## Solution

Block autoindent shifts each line by the first line's delta, but only
when the line's indent kind matches the target kind. A line with no
indentation defaults to `IndentKind::Space`, so under hard tabs it never
matches and gets skipped. An empty indent doesn't really have a kind, so
I let it adopt the target kind before the check. Lines that actually
have space indentation in a tab buffer are still left alone. Normalizing
those felt like a bigger question than this bug, happy to look at it
separately if wanted.

## Testing

New `test_autoindent_block_mode_with_hard_tabs`, same shape as the
snippet in the issue. Fails on main (closing brace stays at column 0),
passes with the fix. `cargo test -p language` and `-p editor` are green,
clippy and fmt too.

## 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 multi-line snippets leaving unindented lines at column 0 when
`hard_tabs` is enabled.
```

## Parents

- [28c2e7d1e4dc9c8df965adf7656f9b1d993c9a23](https://git.cafe/gitcafe/zed/commit/28c2e7d1e4dc9c8df965adf7656f9b1d993c9a23?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/d9ada8487bca20be32c7621e296030c9d68362f5?format=markdown)
