Skip to content

Commit

Permalink
Remove redundant code related to whitespace characters (#563)
Browse files Browse the repository at this point in the history
* Update TributeRange.js

* Update TributeRange.js

* Update TributeRange.js
  • Loading branch information
jwbth authored Nov 30, 2020
1 parent 27d56cb commit de47a92
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/TributeRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,14 @@ class TributeRange {
}

getLastWordInText(text) {
text = text.replace(/\u00A0/g, ' '); // https://stackoverflow.com/questions/29850407/how-do-i-replace-unicode-character-u00a0-with-a-space-in-javascript
var wordsArray;
if (this.tribute.autocompleteSeparator) {
wordsArray = text.split(this.tribute.autocompleteSeparator);
} else {
wordsArray = text.split(/\s+/);
}
var worldsCount = wordsArray.length - 1;
return wordsArray[worldsCount].trim();
var wordsCount = wordsArray.length - 1;
return wordsArray[wordsCount];
}

getTriggerInfo(menuAlreadyActive, hasTrailingSpace, requireLeadingSpace, allowSpaces, isAutocomplete) {
Expand Down Expand Up @@ -334,7 +333,7 @@ class TributeRange {
(
mostRecentTriggerCharPos === 0 ||
!requireLeadingSpace ||
/[\xA0\s]/g.test(
/\s/.test(
effectiveRange.substring(
mostRecentTriggerCharPos - 1,
mostRecentTriggerCharPos)
Expand Down

0 comments on commit de47a92

Please sign in to comment.