code: function getTriggerInfo (ctx, triggerCharSet, requireLeadingSpace, menuAlreadyActive, hasTrailingSpace) {
              /*jshint maxcomplexity:11 */
              // yes this function needs refactoring 
              var selected, path, offset;
              if (selectedElementIsTextAreaOrInput(ctx)) {
                  selected = getDocument(ctx).activeElement;
              } else {
                  // content editable
                  var selectionInfo = getContentEditableSelectedPath(ctx);
                  if (selectionInfo) {
                      selected = selectionInfo.selected;
                      path = selectionInfo.path;
                      offset = selectionInfo.offset;
                  }
              }
              var effectiveRange = getTextPrecedingCurrentSelection(ctx);
  
              if (effectiveRange !== undefined && effectiveRange !== null) {
                  var mostRecentTriggerCharPos = -1;
                  var triggerChar;
                  triggerCharSet.forEach(function(c) {
                      var idx = effectiveRange.lastIndexOf(c);
                      if (idx > mostRecentTriggerCharPos) {
                          mostRecentTriggerCharPos = idx;
                          triggerChar = c;
                      }
                  });
                  if (mostRecentTriggerCharPos >= 0 &&
                          (
                              mostRecentTriggerCharPos === 0 ||
                              !requireLeadingSpace ||
                              /[\xA0\s]/g.test
                              (
                                  effectiveRange.substring(
                                      mostRecentTriggerCharPos - 1,
                                      mostRecentTriggerCharPos)
                              )
                          )
                      )
                  {
                      var currentTriggerSnippet = effectiveRange.substring(mostRecentTriggerCharPos + 1,
                          effectiveRange.length);
  
                      triggerChar = effectiveRange.substring(mostRecentTriggerCharPos, mostRecentTriggerCharPos+1);
                      var firstSnippetChar = currentTriggerSnippet.substring(0,1);
                      var leadingSpace = currentTriggerSnippet.length > 0 &&
                          (
                              firstSnippetChar === ' ' ||
                              firstSnippetChar === '\xA0'
                          );
                      if (hasTrailingSpace) {
                          currentTriggerSnippet = currentTriggerSnippet.trim();
                      }
                      if (!leadingSpace && (menuAlreadyActive || !(/[\xA0\s]/g.test(currentTriggerSnippet)))) {
                          return {
                              mentionPosition: mostRecentTriggerCharPos,
                              mentionText: currentTriggerSnippet,
                              mentionSelectedElement: selected,
                              mentionSelectedPath: path,
                              mentionSelectedOffset: offset,
                              mentionTriggerChar: triggerChar
                          };
                      }
                  }
              }
          }
docs: public