MCPcopy Index your code
hub / github.com/refined-github/refined-github / mentionUser

Function mentionUser

source/features/quick-mention.tsx:42–56  ·  view source on GitHub ↗
({delegateTarget: button}: DelegateEvent)

Source from the content-addressed store, hash-verified

40}
41
42function mentionUser({delegateTarget: button}: DelegateEvent): void {
43 const userMention = getCommentAuthor(button.parentElement!);
44 const newComment = $(fieldSelector);
45 newComment.focus();
46
47 // If the new comment field has selected text, don’t replace it
48 newComment.selectionStart = newComment.selectionEnd;
49
50 // If the cursor is preceded by a space (or is at place 0), don't add a space before the mention
51 const precedingCharacter = newComment.value.slice(newComment.selectionStart - 1, newComment.selectionStart);
52 const spacer = /\s|^$/.test(precedingCharacter) ? '' : ' ';
53
54 // The space after closes the autocomplete box and places the cursor where the user would start typing
55 insertTextIntoField(newComment, `${spacer}${prefixUserMention(userMention)} `);
56}
57
58function addButton(avatar: HTMLElement): void {
59 const userMention = getCommentAuthor(avatar);

Callers

nothing calls this directly

Calls 2

getCommentAuthorFunction · 0.85
prefixUserMentionFunction · 0.85

Tested by

no test coverage detected