Skip to content

Search Replace: Cursor does not move to next match when replace string starts with a newline followed by search string #248209

@CatEatsFishForFree

Description

@CatEatsFishForFree

Does this issue occur when all extensions are disabled?: Yes
No extensions installed.

  • VS Code Version: 1.99.3
  • OS Version: Windows 11 24H2

When executing search and replace by clicking replace button the cursor does not move to the next match when the replace string is the newline followed by the search string. Instead, the first match is replaced repeatedly, preventing sequential replacements.

Steps to Reproduce:

Code:
text text text

  1. Set cursor before first text.
  2. CTRL+H.
  3. Enter search string "text" without quotes.
  4. Enter replace string "
    text1" without quotes. Replace string starts with newline. newline via SHIFT+ENTER.
  5. Click replace button 3 times.
  6. Expected result: "
    text1
    text1
    text1"
  7. Actual result is"

text111 text text" without quotes.

Looks like the cursor sticks in the original line by ignoring the inserted newline causing the same match to be replaced repeatedly instead of progressing to the next occurrence.
Hitting "replace all" however works flawlessly.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugsearch-replaceSearch and replace issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions