Skip to content

feat: add case preservation support via custom :s flag P (#3978) - #10040

Open
ronaldocheruiyot wants to merge 1 commit into
VSCodeVim:masterfrom
ronaldocheruiyot:master
Open

feat: add case preservation support via custom :s flag P (#3978)#10040
ronaldocheruiyot wants to merge 1 commit into
VSCodeVim:masterfrom
ronaldocheruiyot:master

Conversation

@ronaldocheruiyot

Copy link
Copy Markdown

What this PR does / why we need it:
This PR adds support for preserving case during a substitution command (:s), matching the native behavior found in VSCode's built-in Find and Replace functionality.

Because standard Vim uses the lowercase p flag for printing the last matched line, this introduces a custom uppercase P flag to handle case preservation (e.g., running :%s/foo/bar/P will dynamically transform FOO foo Foo into BAR bar Bar).

It intercepts the substitution loop via a custom utility function that checks the original matched string's text layout (UPPERCASE, lowercase, or Title Case) and applies the identical format to the incoming replacement string before writing it to the document transformer.

Which issue(s) this PR fixes
Fixes #3978

Special notes for your reviewer:

  • Added an automated framework unit test under test/cmd_line/substitute.test.ts to validate UPPER, lower, and Title Case execution scenarios simultaneously.
  • Compilation is successful locally via yarn build-dev.

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.

Preserve case support

1 participant