Skip to content

Commit 2b250d9

Browse files
committed
extract iconNameCharacter from doParseLabelWithIcons
1 parent 2499f31 commit 2b250d9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/vs/base/common/codicons.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export namespace CSSIcon {
8686
export const iconNameSegment = '[A-Za-z0-9]+';
8787
export const iconNameExpression = '[A-Za-z0-9\\-]+';
8888
export const iconModifierExpression = '~[A-Za-z]+';
89+
export const iconNameCharacter = '[A-Za-z0-9\\-~]';
8990

9091
const cssIconIdRegex = new RegExp(`^(${iconNameExpression})(${iconModifierExpression})?$`);
9192

src/vs/base/common/iconLabels.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ltrim } from 'vs/base/common/strings';
1010
export const iconStartMarker = '$(';
1111

1212
const iconsRegex = new RegExp(`\\$\\(${CSSIcon.iconNameExpression}(?:${CSSIcon.iconModifierExpression})?\\)`, 'g'); // no capturing groups
13+
const iconNameCharacterRegexp = new RegExp(CSSIcon.iconNameCharacter);
1314

1415
const escapeIconsRegex = new RegExp(`(\\\\)?${iconsRegex.source}`, 'g');
1516
export function escapeIcons(text: string): string {
@@ -103,7 +104,7 @@ function doParseLabelWithIcons(text: string, firstIconIndex: number): IParsedLab
103104
// within icon
104105
else if (currentIconStart !== -1) {
105106
// Make sure this is a real icon name
106-
if (/^[a-z0-9\-~]$/i.test(char)) {
107+
if (iconNameCharacterRegexp.test(char)) {
107108
currentIconValue += char;
108109
} else {
109110
// This is not a real icon, treat it as text

0 commit comments

Comments
 (0)