This is the "smartcase" behavior, described by vim and dtolnay. (cherry picked from commit 32500aa8e0)
32500aa8e0