# Fix invalid number of space characters inserted for tab \(\#27336\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 2e56935997aeb7e0b2b11368dc03ba943472f22c

Requested commit: 2e56935997aeb7e0b2b11368dc03ba943472f22c

Commit: 2e56935997aeb7e0b2b11368dc03ba943472f22c

Tree: dd2339f88fa7a10ca41caa2d2fd0607921af40d0

Author: Rodrigo Freire

Committer: GitHub

## Message

```
Fix invalid number of space characters inserted for tab (#27336)

Closes #25941 

Release Notes:

- Corrected SoftTab indentation handling for lines with mixed spaces and
tabs across .go files and other file types.
- Renamed the editor test `test_tab_with_mixed_whitespace` to
`test_tab_with_mixed_whitespace_rust` as it only tested this behavior
for Rust buffers, which have auto-indentation support. This change
clarifies that the test does not cover default files without
language-specific features.
- Added a new editor test `test_tab_with_mixed_whitespace_txt` to ensure
proper coverage for files with no associated language.

While investigating the issue — initially thought to be Go-related — I
discovered that the underlying problem was how soft tabs were calculated
in `Editor::tab`, given that the problem could also be observed on
`.txt` files

The correct soft tab indentation is now determined by treating all `\t`
characters before the cursor (on the same row) as new indentation
levels, resetting the remainder counter accordingly.


https://github.com/user-attachments/assets/78192e98-2b81-43cb-ae6f-7c48cd17d168
```

## Parents

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

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