Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ function SuggestionMention({
suggestionEndIndex = indexOfFirstSpecialCharOrEmojiAfterTheCursor + selectionEnd;
}

const newLineIndex = value.lastIndexOf('\n', selectionEnd - 1);
const leftString = value.substring(newLineIndex + 1, suggestionEndIndex);
const afterLastBreakLineIndex = value.lastIndexOf('\n', selectionEnd - 1) + 1;
const leftString = value.substring(afterLastBreakLineIndex, suggestionEndIndex);
const words = leftString.split(CONST.REGEX.SPACE_OR_EMOJI);
const lastWord = _.last(words);
const secondToLastWord = words[words.length - 3];
Expand All @@ -215,12 +215,12 @@ function SuggestionMention({

// Detect if the last two words contain a mention (two words are needed to detect a mention with a space in it)
if (lastWord.startsWith('@')) {
atSignIndex = leftString.lastIndexOf(lastWord);
atSignIndex = leftString.lastIndexOf(lastWord) + afterLastBreakLineIndex;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dukenv0307 Won't it have a offset of 1 index because we add 1 to the afterLastBreakLineIndex?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@abdulrahuman5196 abdulrahuman5196 Feb 27, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dukenv0307 It shouldn't offset atSignIndex right? Because it will offset the index of atSignIndex by 1 wrongly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulrahuman5196 The current logic is correct since the leftString is cut off start after the last break line index.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dukenv0307 It shouldn't offset atSignIndex right? Because it will offset the index of atSignIndex by 1 wrongly?

I also tested your concern and here is result if we remove the offer 1 from atSignIndex

Screen.Recording.2024-02-28.at.01.12.40.mov

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thank you checking.

suggestionWord = lastWord;

prefix = suggestionWord.substring(1);
} else if (secondToLastWord && secondToLastWord.startsWith('@') && secondToLastWord.length > 1) {
atSignIndex = leftString.lastIndexOf(secondToLastWord);
atSignIndex = leftString.lastIndexOf(secondToLastWord) + afterLastBreakLineIndex;
suggestionWord = `${secondToLastWord} ${lastWord}`;

prefix = suggestionWord.substring(1);
Expand Down