Skip to content

Commit 628c6da

Browse files
committed
Over-complicated single pass
1 parent 14c1d73 commit 628c6da

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/vs/editor/contrib/linesOperations/linesOperations.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,7 @@ class BackwardsCompatibleRegExp {
10401040

10411041
export class TitleCaseAction extends AbstractCaseAction {
10421042

1043-
public static titleBoundary = new BackwardsCompatibleRegExp('(^|[^\\p{L}\\p{N}])\\p{L}', 'gmu');
1044-
public static apostrophe = new BackwardsCompatibleRegExp('\\p{L}\'\\p{L}', 'gmu');
1043+
public static titleBoundary = new BackwardsCompatibleRegExp('(?:^|[^\\p{L}\\p{N}\']|(?:(?:^|[^\\p{L}\\p{N}])\'))\\p{L}', 'gmu');
10451044

10461045
constructor() {
10471046
super({
@@ -1054,15 +1053,13 @@ export class TitleCaseAction extends AbstractCaseAction {
10541053

10551054
protected _modifyText(text: string, wordSeparators: string): string {
10561055
const titleBoundary = TitleCaseAction.titleBoundary.get();
1057-
const apostrophe = TitleCaseAction.apostrophe.get();
1058-
if (!titleBoundary || !apostrophe) {
1056+
if (!titleBoundary) {
10591057
// cannot support this
10601058
return text;
10611059
}
10621060
return text
10631061
.toLocaleLowerCase()
1064-
.replace(titleBoundary, (b) => b.toLocaleUpperCase())
1065-
.replace(apostrophe, (a) => a.toLocaleLowerCase());
1062+
.replace(titleBoundary, (b) => b.toLocaleUpperCase());
10661063
}
10671064
}
10681065

@@ -1118,6 +1115,6 @@ registerEditorAction(LowerCaseAction);
11181115
if (SnakeCaseAction.caseBoundary.isSupported() && SnakeCaseAction.singleLetters.isSupported()) {
11191116
registerEditorAction(SnakeCaseAction);
11201117
}
1121-
if (TitleCaseAction.titleBoundary.isSupported() && TitleCaseAction.apostrophe.isSupported()) {
1118+
if (TitleCaseAction.titleBoundary.isSupported()) {
11221119
registerEditorAction(TitleCaseAction);
11231120
}

0 commit comments

Comments
 (0)