Skip to content

markdown: Don't adjust indentation when inserting with multiple cursors#40794

Merged
smitbarmase merged 7 commits intozed-industries:mainfrom
vipexv:fix/markdown-multi-cursor-indentation
Dec 4, 2025
Merged

markdown: Don't adjust indentation when inserting with multiple cursors#40794
smitbarmase merged 7 commits intozed-industries:mainfrom
vipexv:fix/markdown-multi-cursor-indentation

Conversation

@vipexv
Copy link
Contributor

@vipexv vipexv commented Oct 21, 2025

Closes #40757

Summary

This PR addresses an issue where Zed incorrectly adjusts the indentation of Markdown lists when inserting text using multiple cursors. Currently:

  • Editing individual lines with a single cursor behaves correctly (no unwanted indentation changes).
  • Using multiple cursors, Zed automatically adjusts the indentation, unlike VS Code, which preserves the existing formatting.

Tasks

  • Implement a new test to verify correct Markdown indentation behavior with multiple cursors.
  • Apply the fix to prevent Zed from adjusting indentation when inserting text on multiple cursors.

Release Notes:

  • Fixed an issue where inserting text with multiple cursors inside a nested Markdown list would cause it to lose its indentation.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 21, 2025
@vipexv
Copy link
Contributor Author

vipexv commented Oct 21, 2025

So far the fix seems to work, the tests also passed locally, but i'm not 100% sure, so i'll be waiting for a team member to take a look at this approach and see if there's any issues with it.

@vipexv vipexv marked this pull request as ready for review October 21, 2025 19:26
@smitbarmase smitbarmase self-assigned this Oct 22, 2025
Copy link
Member

@smitbarmase smitbarmase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's the right approach to fix this bug, since it might affect a lot of languages. Let's not touch handle_input at all.

I wonder if we can fix this by making the Markdown language aware of indents within it. Notice how Python and Bash languages are implemented. You might want to look at this file:

(function_definition) @start.def

And these PRs: #29625 and #33370.

I think the simplest solution would be defining increase_indent_pattern (more here). However, since a Markdown list item that’s a parent and a child look alike, I’m not sure if just this would work but it’s worth trying.

Let me know if you’re up for giving this a try. I can help you land this.

@vipexv
Copy link
Contributor Author

vipexv commented Oct 22, 2025

I honestly thought the same thing, it's why i was skeptical of this approach, i know the tests pass but it could break allot of languages, especially modifying one of the core input functions.

And yeah, i'm 100% willing to give this a try, i'll be taking a deeper look into what you mentioned and move forward with that, thank you!

@vipexv vipexv requested a review from smitbarmase October 23, 2025 22:47
@vipexv
Copy link
Contributor Author

vipexv commented Oct 23, 2025

I added some basic indentation rules. This is my first time working with a schema file, so I’m still learning. I also experimented with defining both increase_indent_pattern and decrease_indent_pattern, i managed to resolved the main issue with that but introduced a few new ones I couldn’t figure out (didn't spend too much time on that approach). The current approach seems to work, though. I’d appreciate it if you could take a look and let me know if there's a better way to handle this!

@vipexv
Copy link
Contributor Author

vipexv commented Oct 28, 2025

Hello @smitbarmase!

I’ve updated the PR based on your feedback (moved the logic to Markdown’s indent rules and reverted the handle_input change).
All checks are passing now, Cculd you take another look when you have a moment? Thank you!

Copy link
Member

@smitbarmase smitbarmase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I added one fix and its test to make sure we don't indent on newline and instead keep the indent from the current line we’re moving from. Sorry for delaying this for so long. Thanks so much.

@vipexv
Copy link
Contributor Author

vipexv commented Dec 4, 2025

No need to apologize at all, and thank you!

@smitbarmase smitbarmase merged commit 9ae77ec into zed-industries:main Dec 4, 2025
24 checks passed
AlpSha pushed a commit to AlpSha/zed that referenced this pull request Dec 5, 2025
…rs (zed-industries#40794)

Closes zed-industries#40757

## Summary

This PR addresses an issue where Zed incorrectly adjusts the indentation
of Markdown lists when inserting text using multiple cursors. Currently:

- Editing individual lines with a single cursor behaves correctly (no
unwanted indentation changes).
- Using multiple cursors, Zed automatically adjusts the indentation,
unlike VS Code, which preserves the existing formatting.

## Tasks
- [x] Implement a new test to verify correct Markdown indentation
behavior with multiple cursors.
- [x] Apply the fix to prevent Zed from adjusting indentation when
inserting text on multiple cursors.

------------------------

Release Notes:

- Fixed an issue where inserting text with multiple cursors inside a
nested Markdown list would cause it to lose its indentation.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
vipexv added a commit to vipexv/zed that referenced this pull request Dec 7, 2025
smitbarmase added a commit that referenced this pull request Dec 8, 2025
…usly (#44381)

Closes #44223

Regressed in #40794 in attempt
to fix #40757. This PR
handles both cases and add more tests around it.

Bug is only in Nightly.

Release Notes:

- N/A
smitbarmase added a commit that referenced this pull request Dec 11, 2025
Builds on #40794 and
#44381

- Fixes the case where creating a new line inside a nested list puts the
cursor correctly under that nested list item.
- Fixes the case where typing a new list item at the expected indent no
longer auto-indents or outdents incorrectly.

Release Notes:

- Fixed an issue in Markdown where new list items weren’t respecting the
expected indentation on type.
@franciskafyi franciskafyi moved this from Community PRs to Done in Quality Week – December 2025 Dec 11, 2025
nrbnlulu pushed a commit to nrbnlulu/zed that referenced this pull request Dec 14, 2025
Builds on zed-industries#40794 and
zed-industries#44381

- Fixes the case where creating a new line inside a nested list puts the
cursor correctly under that nested list item.
- Fixes the case where typing a new list item at the expected indent no
longer auto-indents or outdents incorrectly.

Release Notes:

- Fixed an issue in Markdown where new list items weren’t respecting the
expected indentation on type.
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
…rs (zed-industries#40794)

Closes zed-industries#40757

## Summary

This PR addresses an issue where Zed incorrectly adjusts the indentation
of Markdown lists when inserting text using multiple cursors. Currently:

- Editing individual lines with a single cursor behaves correctly (no
unwanted indentation changes).
- Using multiple cursors, Zed automatically adjusts the indentation,
unlike VS Code, which preserves the existing formatting.

## Tasks
- [x] Implement a new test to verify correct Markdown indentation
behavior with multiple cursors.
- [x] Apply the fix to prevent Zed from adjusting indentation when
inserting text on multiple cursors.

------------------------

Release Notes:

- Fixed an issue where inserting text with multiple cursors inside a
nested Markdown list would cause it to lose its indentation.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
…usly (zed-industries#44381)

Closes zed-industries#44223

Regressed in zed-industries#40794 in attempt
to fix zed-industries#40757. This PR
handles both cases and add more tests around it.

Bug is only in Nightly.

Release Notes:

- N/A
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
Builds on zed-industries#40794 and
zed-industries#44381

- Fixes the case where creating a new line inside a nested list puts the
cursor correctly under that nested list item.
- Fixes the case where typing a new list item at the expected indent no
longer auto-indents or outdents incorrectly.

Release Notes:

- Fixed an issue in Markdown where new list items weren’t respecting the
expected indentation on type.
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
…rs (zed-industries#40794)

Closes zed-industries#40757

## Summary

This PR addresses an issue where Zed incorrectly adjusts the indentation
of Markdown lists when inserting text using multiple cursors. Currently:

- Editing individual lines with a single cursor behaves correctly (no
unwanted indentation changes).
- Using multiple cursors, Zed automatically adjusts the indentation,
unlike VS Code, which preserves the existing formatting.

## Tasks
- [x] Implement a new test to verify correct Markdown indentation
behavior with multiple cursors.
- [x] Apply the fix to prevent Zed from adjusting indentation when
inserting text on multiple cursors.

------------------------

Release Notes:

- Fixed an issue where inserting text with multiple cursors inside a
nested Markdown list would cause it to lose its indentation.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
…usly (zed-industries#44381)

Closes zed-industries#44223

Regressed in zed-industries#40794 in attempt
to fix zed-industries#40757. This PR
handles both cases and add more tests around it.

Bug is only in Nightly.

Release Notes:

- N/A
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
Builds on zed-industries#40794 and
zed-industries#44381

- Fixes the case where creating a new line inside a nested list puts the
cursor correctly under that nested list item.
- Fixes the case where typing a new list item at the expected indent no
longer auto-indents or outdents incorrectly.

Release Notes:

- Fixed an issue in Markdown where new list items weren’t respecting the
expected indentation on type.
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

Development

Successfully merging this pull request may close these issues.

Markdown: Zed should not adjust indentation when inserting text with multiple cursors

2 participants