-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify formatting of perference's name to align vscode #9381
Conversation
@shuyaqian, thank you for your contribution! With your changes, I'm seeing some problems where names that should be split are not being split: You mention in your PR description that the problem occurs with Chinese characters and special characters like the For example |
Thanks, I've revised it. |
Thank you very much! One thing I notice is that the new regex uses ranges like
I haven’t tested every case, but JavaScript’s Punctuation is a challenge. For example something like |
I have a preference for 'SecSolar', which is an acronym, and I don't want it to be 'Sec Solar', but in VSCODE it's also 'Sec Solar'. I think this can be aligned with vscode and ignored for the time being. The rest of the logic is executed according to the pseudocode above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good and the tests are a very nice addition, only very minor issues remaining.
@@ -137,7 +137,17 @@ export class PreferenceTreeGenerator { | |||
} | |||
|
|||
private formatString(string: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private formatString(string: string): string { | |
protected formatString(string: string): string { |
return formatedString.trim(); | ||
} | ||
|
||
private isUpperCase(char: string): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private isUpperCase(char: string): boolean { | |
protected isUpperCase(char: string): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, a test is now failing. Looks like it expects capitalization after white space, as well as string-initially. I think that expectation is incorrect. If you create a preference name in the following form:
"references.My perfectly formatted Display Name"`
VSCode does not capitalize the words after spaces:
So you can simply change the expected output.
Thanks, I've revised it. I don't know why the test cases don't run automatically after force-push🤪,maybe need you to approve. |
@shuyaqian, looks like it did re-run, and there's still a tiny problem: the current code is adding a space in the sequence
You can also run the tests locally: from the |
I ignored the space in front of the uppercase letter, and I modified the criteria, now it's okay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are passing and the code looks good. Thanks for the contribution and for the tests, @shuyaqian!
protected formatString(string: string): string { | ||
let formatedString = string[0].toLocaleUpperCase(); | ||
for (let i = 1; i < string.length; i++) { | ||
if (this.isUpperCase(string[i]) && string[i - 1] !== ' ' && !this.isUpperCase(string[i - 1])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I think this is fine as is - I'll approve it momentarily - but the check !== ' '
could be generalized to regex /\s/
, since not all scripts use the ' ' character.
I will merge this tomorrow, if there are no objections. |
Signed-off-by: shuyaqian <[email protected]>
Thanks, hopefully this will end the PR this time😅 |
Thanks for going along with my expansion of the scope of the PR. I think this is a big improvement over the previous implementation. |
Signed-off-by: shuyaqian [email protected]
What it does
Avoid the problem that if the perference's name contains Chinese characters or special characters like C++ will be filtered.
How to test
Review checklist
Reminder for reviewers