<commit_before>#= require shortcuts_navigation

class @ShortcutsIssueable extends ShortcutsNavigation
  constructor: (isMergeRequest) ->
    super()
    Mousetrap.bind('a', ->
      $('.js-assignee').select2('open')
      return false
    )
    Mousetrap.bind('m', ->
      $('.js-milestone').select2('open')
      return false
    )
    
    if isMergeRequest
      @enabledHelp.push('.hidden-shortcut.merge_requests')
    else
      @enabledHelp.push('.hidden-shortcut.issues')
<commit_msg>Add hotkey for "reply with selected text" to Issueable<commit_after>#= require shortcuts_navigation

class @ShortcutsIssueable extends ShortcutsNavigation
  constructor: (isMergeRequest) ->
    super()
    Mousetrap.bind('a', ->
      $('.js-assignee').select2('open')
      return false
    )
    Mousetrap.bind('m', ->
      $('.js-milestone').select2('open')
      return false
    )
    Mousetrap.bind('r', =>
      @replyWithSelectedText()
      return false
    )

    if isMergeRequest
      @enabledHelp.push('.hidden-shortcut.merge_requests')
    else
      @enabledHelp.push('.hidden-shortcut.issues')

  replyWithSelectedText: ->
    if window.getSelection
      selected = window.getSelection().toString()
      replyField = $('.js-main-target-form #note_note')

      return if selected.trim() == ""

      # Put a '>' character before each non-empty line in the selection
      quote = _.map selected.split("\n"), (val) ->
        "> #{val}\n" if val.trim() != ''

      # If replyField already has some content, add a newline before our quote
      separator = replyField.val().trim() != "" and "\n" or ''

      replyField.val (_, current) ->
        current + separator + quote.join('') + "\n"

      # Trigger autosave for the added text
      replyField.trigger('input')

      # Focus the input field
      replyField.focus()
{'fraction_non_alphanumeric': 0.14207947740881874, 'fraction_numerical': 0.002177463255307567, 'mean_word_length': 2.8132780082987554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5005306', 'n_tokens_mistral': 561, 'n_tokens_neox': 538, 'n_words': 121}