Skip to content

fix: parse escape sequences in regex replacement text #2865

Open
4RH1T3CT0R7 wants to merge 1 commit into
arduino:mainfrom
4RH1T3CT0R7:main
Open

fix: parse escape sequences in regex replacement text #2865
4RH1T3CT0R7 wants to merge 1 commit into
arduino:mainfrom
4RH1T3CT0R7:main

Conversation

@4RH1T3CT0R7
Copy link
Copy Markdown

Motivation

Fixes #2803

When using global search and replace with regex mode enabled, escape sequences like \n in the replacement text are inserted as literal characters instead of
being interpreted as actual newlines. For example, replacing \n\n with \n produces #define hello\n instead of an actual newline character.

Change description

  • Added parseReplaceString() function that converts escape sequences (\n, \t, \r, \) to their actual character representations
  • Created custom SearchInWorkspaceResultTreeWidget that overrides replaceResult() to parse escape sequences when regex mode is enabled
  • Added rebinding in the frontend module to use the custom widget
  • Added unit tests for the escape sequence parser

Other information

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the https://github.com/arduino/arduino-ide/pulls before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 18, 2026

CLA assistant check
All committers have signed the CLA.

@arduino arduino deleted a comment from CLAassistant Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global search and replace with regex does not correctly replace

2 participants