Fix title/camelCase commands stripping leading indentation Fixes#50523
Conversation
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Nice catch, but the fix seems somewhat odd given it's the library that removes the whitespaces, should we fix the rest of the invocations?
There are 6 total in this file but only 3 are being fixed and tested here which seems odd — seems that all of them would benefit from a common method that fixes things via trim_start.
Should we also use trim_end for similar reasons?
Thanks for the review. I updated this PR to centralize the fix and broaden coverage:
|
…-industries#50523) Fixes: zed-industries#48945 Description: The convert:to-title-case, convert:to-upper-camel-case, and convert:to-lower-camel-case editor commands were stripping leading whitespace from each line of a multi-line selection. Root cause: The conversion functions split on whitespace using .split_whitespace() and then joined the resulting words, discarding any leading spaces/tabs before the first word on each line. Fix: Each line now preserves its leading whitespace by capturing and re-prepending it before applying the case conversion. Tests: Added test cases covering multi-line selections with indentation for all three commands. Video : [bug1fix.webm](https://github.com/user-attachments/assets/f4d25c55-bc6d-44e6-a989-7d9b4bc59ac9) Release Notes: - Fixed trailing whitespace handling on text case changes
Fixes: #48945
Description:
The convert:to-title-case, convert:to-upper-camel-case, and convert:to-lower-camel-case editor commands were stripping leading whitespace from each line of a multi-line selection.
Root cause: The conversion functions split on whitespace using .split_whitespace() and then joined the resulting words, discarding any leading spaces/tabs before the first word on each line.
Fix: Each line now preserves its leading whitespace by capturing and re-prepending it before applying the case conversion.
Tests: Added test cases covering multi-line selections with indentation for all three commands.
Video :
bug1fix.webm
Release Notes: