Skip to content

vim: Respect auto_indent setting in o/O commands - #53620

Merged
ConradIrwin merged 1 commit into
zed-industries:mainfrom
davidalecrim1:worktree-zed-vim-new-line
Apr 22, 2026
Merged

vim: Respect auto_indent setting in o/O commands#53620
ConradIrwin merged 1 commit into
zed-industries:mainfrom
davidalecrim1:worktree-zed-vim-new-line

Conversation

@davidalecrim1

@davidalecrim1 davidalecrim1 commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #53570

  • o and O in normal mode were unconditionally copying the current line's indentation into the new line, ignoring the auto_indent setting entirely
  • When auto_indent: "none" is set, new lines created by o/O now start at column 0 as expected
  • When auto_indent is preserve_indent or syntax_aware, behavior is unchanged

The fix reads language_settings_at for the relevant row and splits edits into two paths: editor.edit() (no autoindent) for None, and editor.edit_with_autoindent() for everything else — mirroring the approach already used by the non-vim Newline action.

Test plan

  • Added test_o_auto_indent_none: verifies o/O produce column-0 lines with auto_indent: "none", including edge cases (first line, empty line)
  • Added test_o_preserve_indent: verifies o/O copy the current line's indentation with auto_indent: "preserve_indent" (regression guard)
  • Existing neovim-backed tests (test_o, test_insert_line_above, test_o_comment) continue to pass

Release Notes:

  • Fixed vim o/O commands ignoring the auto_indent: "none" setting, causing new lines to inherit indentation instead of starting at column 0

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 10, 2026
@zed-codeowner-coordinator
zed-codeowner-coordinator Bot requested review from a team, SomeoneToIgnore and as-cii and removed request for a team April 10, 2026 11:53
@SomeoneToIgnore
SomeoneToIgnore requested review from dinocosta and removed request for SomeoneToIgnore April 10, 2026 12:16
@ConradIrwin

Copy link
Copy Markdown
Member

Neat, thanks for the fix.

@ConradIrwin
ConradIrwin enabled auto-merge (squash) April 20, 2026 17:28
When `auto_indent` is set to `none`, the vim `o` and `O` commands were
still copying the current line's indentation into the new line, ignoring
the user's setting. New lines now start at column 0 as expected.

Fixes zed-industries#53570
auto-merge was automatically disabled April 22, 2026 09:41

Head branch was pushed to by a user without write access

@davidalecrim1
davidalecrim1 force-pushed the worktree-zed-vim-new-line branch from ae230cd to 73d2947 Compare April 22, 2026 09:41
@davidalecrim1

Copy link
Copy Markdown
Contributor Author

@ConradIrwin I had to rebase this given a failing test that came from main unrelated to this change.

@ConradIrwin
ConradIrwin enabled auto-merge (squash) April 22, 2026 16:34
@ConradIrwin

Copy link
Copy Markdown
Member

Thanks, and sorry for missing that.

@ConradIrwin
ConradIrwin merged commit bcf4c71 into zed-industries:main Apr 22, 2026
31 checks passed
@phdavis1027 phdavis1027 mentioned this pull request Apr 24, 2026
5 tasks
kathbigra pushed a commit to kathbigra/zed that referenced this pull request May 10, 2026
## Summary

Closes zed-industries#53570

- `o` and `O` in normal mode were unconditionally copying the current
line's indentation into the new line, ignoring the `auto_indent` setting
entirely
- When `auto_indent: "none"` is set, new lines created by `o`/`O` now
start at column 0 as expected
- When `auto_indent` is `preserve_indent` or `syntax_aware`, behavior is
unchanged

The fix reads `language_settings_at` for the relevant row and splits
edits into two paths: `editor.edit()` (no autoindent) for `None`, and
`editor.edit_with_autoindent()` for everything else — mirroring the
approach already used by the non-vim `Newline` action.

## Test plan

- Added `test_o_auto_indent_none`: verifies `o`/`O` produce column-0
lines with `auto_indent: "none"`, including edge cases (first line,
empty line)
- Added `test_o_preserve_indent`: verifies `o`/`O` copy the current
line's indentation with `auto_indent: "preserve_indent"` (regression
guard)
- Existing neovim-backed tests (`test_o`, `test_insert_line_above`,
`test_o_comment`) continue to pass

Release Notes:

- Fixed vim `o`/`O` commands ignoring the `auto_indent: "none"` setting,
causing new lines to inherit indentation instead of starting at column 0
Zenor27 pushed a commit to Zenor27/zed that referenced this pull request Jul 4, 2026
## Summary

Closes zed-industries#53570

- `o` and `O` in normal mode were unconditionally copying the current
line's indentation into the new line, ignoring the `auto_indent` setting
entirely
- When `auto_indent: "none"` is set, new lines created by `o`/`O` now
start at column 0 as expected
- When `auto_indent` is `preserve_indent` or `syntax_aware`, behavior is
unchanged

The fix reads `language_settings_at` for the relevant row and splits
edits into two paths: `editor.edit()` (no autoindent) for `None`, and
`editor.edit_with_autoindent()` for everything else — mirroring the
approach already used by the non-vim `Newline` action.

## Test plan

- Added `test_o_auto_indent_none`: verifies `o`/`O` produce column-0
lines with `auto_indent: "none"`, including edge cases (first line,
empty line)
- Added `test_o_preserve_indent`: verifies `o`/`O` copy the current
line's indentation with `auto_indent: "preserve_indent"` (regression
guard)
- Existing neovim-backed tests (`test_o`, `test_insert_line_above`,
`test_o_comment`) continue to pass

Release Notes:

- Fixed vim `o`/`O` commands ignoring the `auto_indent: "none"` setting,
causing new lines to inherit indentation instead of starting at column 0
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
## Summary

Closes zed-industries#53570

- `o` and `O` in normal mode were unconditionally copying the current
line's indentation into the new line, ignoring the `auto_indent` setting
entirely
- When `auto_indent: "none"` is set, new lines created by `o`/`O` now
start at column 0 as expected
- When `auto_indent` is `preserve_indent` or `syntax_aware`, behavior is
unchanged

The fix reads `language_settings_at` for the relevant row and splits
edits into two paths: `editor.edit()` (no autoindent) for `None`, and
`editor.edit_with_autoindent()` for everything else — mirroring the
approach already used by the non-vim `Newline` action.

## Test plan

- Added `test_o_auto_indent_none`: verifies `o`/`O` produce column-0
lines with `auto_indent: "none"`, including edge cases (first line,
empty line)
- Added `test_o_preserve_indent`: verifies `o`/`O` copy the current
line's indentation with `auto_indent: "preserve_indent"` (regression
guard)
- Existing neovim-backed tests (`test_o`, `test_insert_line_above`,
`test_o_comment`) continue to pass

Release Notes:

- Fixed vim `o`/`O` commands ignoring the `auto_indent: "none"` setting,
causing new lines to inherit indentation instead of starting at column 0
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
## Summary

Closes zed-industries#53570

- `o` and `O` in normal mode were unconditionally copying the current
line's indentation into the new line, ignoring the `auto_indent` setting
entirely
- When `auto_indent: "none"` is set, new lines created by `o`/`O` now
start at column 0 as expected
- When `auto_indent` is `preserve_indent` or `syntax_aware`, behavior is
unchanged

The fix reads `language_settings_at` for the relevant row and splits
edits into two paths: `editor.edit()` (no autoindent) for `None`, and
`editor.edit_with_autoindent()` for everything else — mirroring the
approach already used by the non-vim `Newline` action.

## Test plan

- Added `test_o_auto_indent_none`: verifies `o`/`O` produce column-0
lines with `auto_indent: "none"`, including edge cases (first line,
empty line)
- Added `test_o_preserve_indent`: verifies `o`/`O` copy the current
line's indentation with `auto_indent: "preserve_indent"` (regression
guard)
- Existing neovim-backed tests (`test_o`, `test_insert_line_above`,
`test_o_comment`) continue to pass

Release Notes:

- Fixed vim `o`/`O` commands ignoring the `auto_indent: "none"` setting,
causing new lines to inherit indentation instead of starting at column 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vim: normal mode o/O does not respect auto_indent: "none"

5 participants