Skip to content

Commit

Permalink
Merge pull request #17551 from dukenv0307/fix/16626
Browse files Browse the repository at this point in the history
Update regex to split leftword and prefix to highlight
  • Loading branch information
PauloGasparSv authored Apr 24, 2023
2 parents 3066281 + 8455fbb commit acb4cc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,9 @@ const CONST = {
CODE_2FA: /^\d{6}$/,
ATTACHMENT_ID: /chat-attachments\/(\d+)/,
HAS_COLON_ONLY_AT_THE_BEGINNING: /^:[^:]+$/,
NEW_LINE_OR_WHITE_SPACE: /[\n\s]/g,

// eslint-disable-next-line no-misleading-character-class
NEW_LINE_OR_WHITE_SPACE_OR_EMOJI: /[\n\s\p{Extended_Pictographic}\u200d\u{1f1e6}-\u{1f1ff}\u{1f3fb}-\u{1f3ff}\u{e0020}-\u{e007f}\u20E3\uFE0F]|[#*0-9]\uFE0F?\u20E3/gu,

// Define the regular expression pattern to match a string starting with a colon and ending with a space or newline character
EMOJI_REPLACER: /^:[^\n\r]+?(?=$|\s)/,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class ReportActionCompose extends React.Component {
* @returns {Boolean}
*/
isEmojiCode(str, pos) {
const leftWords = str.slice(0, pos).split(CONST.REGEX.NEW_LINE_OR_WHITE_SPACE);
const leftWords = str.slice(0, pos).split(CONST.REGEX.NEW_LINE_OR_WHITE_SPACE_OR_EMOJI);
const leftWord = _.last(leftWords);

return CONST.REGEX.HAS_COLON_ONLY_AT_THE_BEGINNING.test(leftWord) && leftWord.length > 2;
Expand Down Expand Up @@ -975,7 +975,7 @@ class ReportActionCompose extends React.Component {
comment={this.state.value}
updateComment={newComment => this.setState({value: newComment})}
colonIndex={this.state.colonIndex}
prefix={this.state.value.slice(this.state.colonIndex + 1).split(' ')[0]}
prefix={this.state.value.slice(this.state.colonIndex + 1, this.state.selection.start)}
onSelect={this.insertSelectedEmoji}
isComposerFullSize={this.props.isComposerFullSize}
preferredSkinToneIndex={this.props.preferredSkinTone}
Expand Down

0 comments on commit acb4cc7

Please sign in to comment.