[BUG] Tab-indented code renders without indentation in Write/create-file preview (file content is correct)

Resolved 💬 2 comments Opened Jun 12, 2026 by eetann Closed Jun 16, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When the Write (create file) tool previews code that uses TAB characters for indentation, the preview drops the indentation entirely — every tab-indented line is shown flush against the left margin. Lines indented with spaces render correctly in the same preview.

The actual file written to disk is correct: the tab characters are preserved. Since the file content is fine and only the preview looks wrong, I think this is likely a display issue in Claude Code's diff/preview renderer rather than a problem with the file content — though I'm not certain of the exact cause.

Other tools (e.g. bat, Neovim) display the exact same file with correct tab indentation, so the file itself is fine.

What Should Happen?

Tab characters in the Write/create-file preview should be expanded to a tab stop (like bat/Neovim/most editors do), so tab-indented lines appear indented in the preview — matching what actually gets written to disk.

Error Messages/Logs

(no errors — display-only issue)

Steps to Reproduce

  1. Start Claude Code with a clean config dir to rule out local settings:

``
CLAUDE_CONFIG_DIR=~/.claude_test claude
``

  1. Send this prompt:

``
Create a file at
example.ts` with two functions.

  • For the first function, indent every line inside it with a REAL TAB character (\t), not spaces.
  • For the second function, indent every line inside it with 2 SPACES.

Do not run any formatter or linter. Write the file exactly as specified.
```

  1. Look at the Write tool preview before accepting it.

Observed: The first function (TAB-indented) shows no indentation; the second function (space-indented) is correctly indented.

Confirming the written file is actually correct (^I = tab):

$ cat -vte example.ts
function first(a: number, b: number): number {$
^Iconst sum = a + b;$
^Iconst doubled = sum * 2;$
^Ireturn doubled;$
}$
$
function second(a: number, b: number): number {$
  const sum = a + b;$
  const doubled = sum * 2;$
  return doubled;$
}$

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.174

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

I think this is not terminal-specific. It reproduces regardless of the terminal/multiplexer:

  • WezTerm + tmux 3.6a (TERM=tmux-256color)
  • macOS default Terminal.app
  • tmux

Because the indentation is completely gone (not just rendered at the wrong width), the tab characters appear to be stripped/treated as zero-width inside Claude Code's preview renderer before reaching the terminal — rather than being passed through to the terminal as literal tabs.

OS: macOS 26.3.1 (build 25D2128)

(Screenshot of the Write preview attached below — first function = TAB, no indentation; second function = spaces, correctly indented.)

<img width="749" height="810" alt="Image" src="https://github.com/user-attachments/assets/0f7a5e4f-ed1a-45e7-9b3f-65dba26c6688" />

<img width="464" height="443" alt="Image" src="https://github.com/user-attachments/assets/cd184733-15f7-418f-9ee8-e00134371936" />

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗