Skip to content

Commit

Permalink
Updated function name
Browse files Browse the repository at this point in the history
  • Loading branch information
alitoshmatov committed Jul 17, 2023
1 parent 31096c5 commit e1580b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/libs/ComposerUtils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ function canSkipTriggerHotkeys(isSmallScreenWidth, isKeyboardShown) {
}

/**
* Find length of common ending of two strings
* @param {String} str1
* @param {String} str2
* @returns {Number}
* Returns the length of the common suffix between two input strings.
* The common suffix is the number of characters shared by both strings
* at the end (suffix) until a mismatch is encountered.
*
* @param {string} str1
* @param {string} str2
* @returns {number} The length of the common suffix between the strings.
*/
function getCommonEndingLength(str1, str2) {
function getCommonSuffixLength(str1, str2) {
let i = 0;
while (str1[str1.length - 1 - i] === str2[str2.length - 1 - i]) {
i++;
}
return i;
}

export {getNumberOfLines, updateNumberOfLines, insertText, canSkipTriggerHotkeys, getCommonEndingLength};
export {getNumberOfLines, updateNumberOfLines, insertText, canSkipTriggerHotkeys, getCommonSuffixLength};
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ class ReportActionCompose extends React.Component {
value: newComment,
};
if (comment !== newComment) {
const remainder = ComposerUtils.getCommonEndingLength(comment, newComment);
const remainder = ComposerUtils.getCommonSuffixLength(comment, newComment);
newState.selection = {
start: newComment.length - remainder,
end: newComment.length - remainder,
Expand Down

0 comments on commit e1580b5

Please sign in to comment.