Skip to content

Fix vim increment/decrement on Markdown list markers#47978

Merged
dinocosta merged 2 commits intozed-industries:mainfrom
lex00:fix/vim-increment-markdown-list-47761
Feb 4, 2026
Merged

Fix vim increment/decrement on Markdown list markers#47978
dinocosta merged 2 commits intozed-industries:mainfrom
lex00:fix/vim-increment-markdown-list-47761

Conversation

@lex00
Copy link
Copy Markdown
Contributor

@lex00 lex00 commented Jan 30, 2026

Summary

  • Fixed vim Ctrl+A (increment) and Ctrl+X (decrement) not working on Markdown ordered list markers like 1., 2., etc.

Root Cause

In find_target(), when a . was encountered after a number, the search state was reset unconditionally. This caused 1. text to skip the 1 and find nothing to increment.

Fix

Modified the . handling to terminate the match (instead of reset) when:

  • We already have a valid number
  • The number starts at or after the cursor position
  • The next character is not a digit

This correctly handles both 1. text (increments 1) and 111..2 (skips 111, increments 2).

Test plan

  • Added test_increment_markdown_list_markers covering increment, decrement, multi-digit markers, and count-based increment
  • All 19 existing increment tests pass

Closes #47761

Release Notes:

  • Fixed vim increment (ctrl-a) and decrement (ctrl-x) not working on Markdown ordered list markers like 1., 2., etc.

🤖 Generated with Claude Code

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 30, 2026
Copy link
Copy Markdown
Member

@dinocosta dinocosta left a comment

Choose a reason for hiding this comment

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

@lex00 Is this working on your end? Just checked out these changes and they don't seem to be working as intended on Markdown list markers ▼

CleanShot.2026-02-02.at.12.29.19.mp4

@lex00
Copy link
Copy Markdown
Contributor Author

lex00 commented Feb 2, 2026

Hi @dinocosta, I'm so sorry about that, I am using these issues to help me learn about Zed's codebase as I have something of my own that I want to integrate into Zed :)

I truly appreciate your patience and I promise I am taking notes and I will use your testing example to validate before I commit again.

@lex00 lex00 marked this pull request as draft February 3, 2026 05:44
@lex00 lex00 marked this pull request as ready for review February 3, 2026 07:23
@lex00
Copy link
Copy Markdown
Contributor Author

lex00 commented Feb 3, 2026

hey, my mistake - I was testing with the installed Zed app instead of building from the branch.

It works fine with cargo run --release.

also converted the test to use NeovimBackedTestContext so it validates against real neovim now.

@lex00 lex00 force-pushed the fix/vim-increment-markdown-list-47761 branch from 8f9eb3b to 7eea3f6 Compare February 3, 2026 07:31
Copy link
Copy Markdown
Member

@dinocosta dinocosta left a comment

Choose a reason for hiding this comment

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

Hi @dinocosta, I'm so sorry about that, I am using these issues to help me learn about Zed's codebase as I have something of my own that I want to integrate into Zed :)

I truly appreciate your patience and I promise I am taking notes and I will use your testing example to validate before I commit again.

No worries! In general, it’s better to only open Pull Requests once you’ve fully tested your changes and they’re ready to be reviewed. Otherwise a maintainer might spend time reviewing changes that weren’t meant to be reviewed yet. This helps us keep the review queue focused on things that are ready to land 🙂

I've taken a second look at the changes and, even though they seem to be working, they seem to be working only on a very specific case, only on the first element in the list and only if there's no text before it?

Here's a quick screen recording showing Neovim's (even though it doesn't have the filetype set to Markdown) next to the changes in this branch ▼

CleanShot.2026-02-03.at.10.39.45.mp4

I believe that we'd like for ctrl-a and ctrl-x to work on any of the list elements and in any scenario 🤔

@lex00
Copy link
Copy Markdown
Contributor Author

lex00 commented Feb 3, 2026

Thank you again for the detailed follow up, I promise I DID build and test Zed :D but obviously I didn't check enough items, and I'll get a better fix up today.

…mbers

Two fixes for vim ctrl-a/ctrl-x:

1. Markdown list markers on non-first lines now work. When cursor is on "1"
   in "text\n1. item", the backward scan stopped at the newline but left
   the offset pointing at it, causing the forward scan to immediately break.
   Now we skip past the newline so the forward scan finds the number.

2. Negative numbers with cursor on the digit now work with trailing dots.
   For "-1." with cursor on "1", the dot handling now recognizes the cursor
   is within the number (not just at/before its start) and ends the match.

Fixes zed-industries#47761

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@lex00 lex00 force-pushed the fix/vim-increment-markdown-list-47761 branch from 7eea3f6 to 046ea39 Compare February 3, 2026 19:55
@lex00
Copy link
Copy Markdown
Contributor Author

lex00 commented Feb 3, 2026

zed-vim-inc-dec.mov

This seems to work better, open to suggestions

Copy link
Copy Markdown
Member

@dinocosta dinocosta left a comment

Choose a reason for hiding this comment

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

Thank you for tackling the provided feedback @lex00 ! 🙂

I've pushed a small commit – 81963d8 – just refactoring a bit of the code and removing some tests that I feel are not necessary. Will merge now! 👍

@dinocosta dinocosta enabled auto-merge (squash) February 4, 2026 23:48
@dinocosta dinocosta merged commit 2b5386b into zed-industries:main Feb 4, 2026
28 checks passed
rtfeldman pushed a commit that referenced this pull request Feb 5, 2026
`find_target()` failed to match numbers followed by a dot and a
non-digit (e.g. `1. item`), because the dot unconditionally reset
the scan state, discarding the number. Additionally, numbers at the
start of non-first lines were missed because the backward scan
stopped on the preceding newline and the forward scan immediately
broke on it.

Closes #47761

Release Notes:

- Fixed vim increment (`ctrl-a`) and decrement (`ctrl-x`) not working on Markdown ordered list markers like `1.`, `2.`, etc.

---------

Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: dino <[email protected]>
@lex00 lex00 deleted the fix/vim-increment-markdown-list-47761 branch March 1, 2026 20:21
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 increment/decrement doesn't work on Markdown ordered list markers

2 participants